Created
March 29, 2021 15:49
-
-
Save jbratu/45675d3af94a29c2d9d5a4258c126355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CS_DETACH_VOLUMES_STARTING_WITH(void) | |
StartingPrefix = '\\server\share\' | |
StartingPrefixLen = Len(StartingPrefix) | |
declare function Set_FSError | |
$Insert Logical | |
*Readnext through the systables which contains a list of currently attached tables. | |
TABLE_NAME = "SYSTABLES" | |
open TABLE_NAME To TABLE else | |
status = Set_FSError() | |
return | |
End | |
select TABLE | |
Done = False$ | |
Loop | |
ReadNext @ID else Done = True$ | |
Until Done Do | |
read @RECORD From TABLE, @ID Then | |
Gosub processRecord | |
End | |
Repeat | |
return | |
* | |
* End Main | |
* | |
processRecord: | |
//Don't bother processing Index or Dictionary tables | |
If @ID[1,1] EQ "!" Then Return | |
If @ID[1,5] EQ "DICT." Then Return | |
//Check the volume against certain system volumes and exclude them | |
Vol = Field(@RECORD<1>, "*", 2) | |
*Exclude tables with no volume | |
If Vol = '' Then Return | |
If Vol[1,StartingPrefixLen] _EQC StartingPrefix then | |
Call Detach_Volume(VOL) | |
Call Set_Status(0) | |
end | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment