home *** CD-ROM | disk | FTP | other *** search
- /* INFOCOLL - Searches system drive(s) for .HLP and .INF files
- and creates program objects for them in a destination folder
-
- Use it if you like it. Don't if you don't. No legalese.
-
- (c) 1999 Marcus de Geus
- marcus@degeus.com
- http://www.degeus.com
-
- ***************************************************************/
-
- signal on Halt /* handle halt condition */
-
- say 'This program searches one or more system drives for .HLP and .INF' /* info */
- say 'files and for each file found creates a VIEW.EXE program object' /* info */
- say 'in a destination folder.' /* info */
- say '' /* empty line */
-
- if (\LoadREXXUtils()) then /* if we cannot load the REXX utilities */
- do
- call Halt /* quit */
- end
-
- say 'Drive(s) to search (separate with spaces):' /* info */
- parse pull DrivesInput /* get a list of drives to search */
-
- if (DrivesInput = '') then /* if we have no drives to search */
- do
- call Halt /* just quit */
- end
-
- DriveMap = sysdrivemap(,'USED') /* get a list of all the drives currently in use */
- DriveList = '' /* start with nothing */
-
- do words(DrivesInput) /* for each of the drives requested */
- parse var DrivesInput OneDrive DrivesInput /* get the drive name */
- OneDrive = translate(strip(OneDrive,'T',':'))||':' /* reshape it into an uppercase word followed by one colon */
- if (pos(OneDrive,DriveMap) = 0) then /* if it is not in the official list */
- do
- call beep 333,333 /* signal */
- say OneDrive||' is not a valid drive' /* report */
- call Halt /* and quit */
- end
- else /* if it is in the list */
- do
- DriveList = DriveList||' '||OneDrive /* add it to our own list */
- end
- end
-
- Destination = GetLoc('Enter the name of the destination folder:') /* get the destination folder */
-
- if (Destination = '') then /* if we have no destination */
- do
- call beep 333,333 /* signal */
- call Halt /* just quit */
- end
-
- if (words(DriveList) > 1) then /* if we have more than one drive */
- do
- Plural = 's' /* we need a plural "s" */
- end
- else /* if we have only one drive to search */
- do
- Plural = '' /* we don't need the extra "s" */
- end
- say '' /* empty line */
- say 'Drive'||Plural||' to search:'||DriveList /* report */
- say 'Destination = '||Destination /* report */
- say '' /* empty line */
-
- Count = 0 /* reset the counter */
- do words(DriveList) /* for each drive in the list */
- parse var DriveList Drive DriveList /* get the next drive */
- Count = Count + CollectInfo(Drive,Destination,'HLP') /* look for HLP files*/
- Count = Count + CollectInfo(Drive,Destination,'INF') /* and look for INF files */
- end
-
- say '' /* empty line */
- say Count||' program objects created in '||Destination /* report */
-
- call Halt /* that's all, folks! */
-
-
-
- /***************************************************************/
-
- CollectInfo: procedure /* does the actual collecting */
-
- parse arg Drive,Destination,FileType /* get the arguments */
-
- say 'Looking for '||FileType||' files on '||Drive /* report */
-
- Counter = 0 /* reset the counter */
- call sysfiletree Drive||'\*.'||FileType,'Files.','FOS' /* look for the files in the root and subdirectories */
-
- do Index = 1 to Files.0 /* for each of the files in filespec, do */
-
- ObjectTitle = '' /* clear object title */
-
- call stream Files.Index,'C','OPEN READ' /* open the source file for reading */
- Input = CharIn(Files.Index,1,3) /* get the first three bytes */
-
- If (Input = 'HSP') then /* if it is a HLP or INF file */
- do
- Position = 108 /* this is where the file title should be in the file */
- do while Position >< 0 /* start moving through the file until Position gets set to 0 */
- Input = CharIn(Files.Index,Position,1) /* read one character from the file */
- If (C2D(Input) >< 0) then /* as long as it is not a null byte */
- do
- ObjectTitle = ObjectTitle||Input /* add it to the title */
- Position = Position + 1 /* up the counter */
- end
- else /* if we find a null byte */
- do
- Position = 0 /* we're finished */
- end
- end
- end
-
- call stream Files.Index,'C','CLOSE' /* close the source file */
-
- if (ObjectTitle = '') then /* If no title was found */
- do
- ObjectTitle = '_Untitled' /* create a dummy title */
- end
-
- ObjectTitle = ObjectTitle||d2c(10)||'('||Files.Index||')' /* add the file path on a separate line to complete the title */
- Params = 'EXENAME=VIEW.EXE;PARAMETERS='||Files.Index||';' /* the parameters to use for the program object */
-
- if (syscreateobject('WPProgram',ObjectTitle,Destination,Params)) then /* if we can create a program object */
- do
- Counter = Counter + 1 /* up the counter */
- end
- else /* if we cannot create it */
- do
- say 'Cannot create program object for : '||Files.Index /* report */
- end
-
- end
-
- say Counter||' '||FileType||' files found' /* report */
-
- return Counter /* end of CollectInfo */
-
-
- /*****************************************************************/
-
- GetLoc: procedure /* gets RexxMail destination folder */
-
- parse arg Message /* get the message */
-
- say Message /* report */
-
- parse pull Location /* get the location*/
-
- Location = strip(Location,'B',' ') /* get rid of any leading and trailing blanks */
- Location = strip(Location,'T','\') /* get rid of any trailing backslash */
- if (Location = '') then /* if we have nothing */
- do
- say 'No location entered' /* report */
- return '' /* return empty */
- end
-
- DriveLetter = filespec('D',Location) /* get any drive letter from the new location */
- if (DriveLetter = '') then /* if there is no drive letter */
- do
- say 'The location must include a drive letter' /* report */
- return '' /* return empty */
- end
-
- call sysfiletree Location,'Loc.','DO' /* look for the new location */
- if (Loc.0 = 0) then /* if it is not found */
- do
- say '"'||Location||'" does not exist; should the folder be created?' /* report */
- say 'Type Y to confirm, any other key to abort; finish with [Enter]' /* report */
- parse upper pull Confirm /* get a reply in upper case */
- Confirm = strip(Confirm,'B',' ') /* get rid of blanks */
- if (substr(Confirm,1,1) >< 'Y') then /* if it is not a yes */
- do
- return '' /* return empty */
- end
-
- say 'Creating folder: '||Location /* report */
- if (sysmkdir(Location) >< 0) then /* if we cannot create the new location folder */
- do
- say 'Cannot create '||Location /* report */
- return '' /* return empty */
- end
-
- end
-
- return Location /* return with the new location */
-
-
- /***************************************************************/
-
- LoadREXXUtils: procedure /* loads the REXX utilities library */
-
- Result = 1 /* start with a good result */
-
- if rxfuncquery('SysLoadFuncs') then /* if it is not already loaded */
- do
- if (rxfuncadd('SysLoadFuncs','RexxUtil','SysLoadFuncs') >< 0) then /* if we cannot add it */
- do
- call beep 333,333 /* signal */
- say 'Error : Cannot register Rexx Utilities library' /* report */
- Result = 0 /* bad result */
- end
- else /* if we can add it */
- do
- if (SysLoadFuncs() = 0) then /* if we cannot load it */
- do
- say 'Error : Cannot load Rexx Utilities library' /* report */
- Result = 0 /* bad result */
- end
- end
- end
-
- return Result /* end of LoadREXXUtils */
-
- /***************************************************************/
-
- Halt: /* handles halt condition */
-
- exit /* that's all, folks! */
-