home *** CD-ROM | disk | FTP | other *** search
- /* MKBOARD.REXX: Construct Pro-Board's PCB index file, BOARD
- $VER: MKBOARD V1.0 */
-
- /* Written by Jeff Lindstrom ©1992 EP Systems */
-
- address command
-
- /* Add the Support Library if not already in the system */
- IF ~SHOW('L', 'rexxsupport.library') THEN
- CALL ADDLIB('rexxsupport.library',0,-30)
-
- /* If no argument provided, first check for configuration file pcb.conf.
- If pcb.conf not found, use current directory as PCB data directory.
- If argument is provided, check that it is a valid path.
- */
- IF ARG(1, 'Omitted') THEN
- DO
- IF EXISTS('pcb.conf') THEN
- DO
- SAY 'Found configuration file pcb.conf'
- IF ~(OPEN('DataDir','pcb.conf', 'r')) THEN
- DO
- SAY "Couldn't open the configuration file pcb.conf"
- EXIT
- END
-
- /* Get Data directory from pcb.conf */
- PARSE VALUE STATEF('pcb.conf') WITH Type Size Other
- PCBconf = READCH('DataDir', Size)
- Len = INDEX(PCBconf, '00'x) - 1
- PCBdir = SUBSTR(PCBconf, 1, Len)
- SAY "PCB data directory set to" PCBdir
- CALL CLOSE('DataDir')
- END
- ELSE /* No configuration file; use current directory */
- DO
- 'CD >T:CONFIGURATION'
- 'ECHO "Using current directory: " NOLINE'
- 'TYPE T:CONFIGURATION'
- CALL OPEN('DataDir', 'T:CONFIGURATION', 'r')
- PCBdir = READLN('DataDir')
-
- /* Last character must be a Directory or Subdirectory marker */
- IF ~( (SUBSTR(PCBdir, LENGTH(PCBdir), 1)) = ':') THEN PCBdir = PCBdir || '/'
-
- CALL CLOSE('DataDir')
- 'DELETE >NIL: T:CONFIGURATION'
- END
- END
- ELSE /* Directory specified; correct format & verify existance */
- DO
- PCBdir = ARG(1)
- /* If no directory or sub-directory marker (':' or '/') is present,
- add a directory marker to end of text.
- This assumes that PCB data directory is not a sub-directory of
- the current directory (which hasn't occurred in my experience).
- */
- IF ~(VERIFY(PCBdir, ':/')) THEN PCBdir = PCBdir || ':'
- LastChar = (SUBSTR(PCBdir, LENGTH(PCBdir), 1))
- /* If the last character is not ':' or '/', add '/' (the ':' would
- already be in the body of the text.
- */
- IF ((INDEX(':/', LastChar)) = 0) THEN PCBdir = PCBdir || '/'
- IF ~EXISTS(PCBdir) THEN
- DO
- SAY "Directory path doesn't exist."
- EXIT
- END
- END
-
- /* Set clock ahead so dates are LISTed in the preferred format. */
- /* Yeah, I KNOW this CAN cause problems in a multitasking system. */
- /* If you want to write the proper sub-routine, be my guest. */
- 'DATE 01-Jan-00'
-
- /* Read default directory */
- /* NOTE: Keep Quotes around PCBdir#?PCB so that
- included spaces don't obstruct listing.
- Also, sort the list alphabetically.
- */
- 'LIST TO T:PCBlist "'PCBdir'#?PCB" LFORMAT="%N %12L %17D %9T"'
- PARSE VALUE STATEF('T:PCBlist') WITH Type Size Other
- IF (Size = 0) THEN
- DO
- SAY "No PCB data files in this directory."
- 'DELETE >NIL: T:PCBlist'
- EXIT
- END
-
- 'SORT T:PCBlist T:PCBlist'
-
- /* Reset clock */
- 'SETCLOCK LOAD'
-
- /* Reformat date string */
- CALL OPEN('PCBfiles', 'T:PCBlist', 'r')
-
- IF ~(OPEN('BOARDfiles', PCBdir'BOARD', 'w')) THEN
- DO
- SAY "Could not open PCB index file, "PCBdir"BOARD."
- EXIT
- END
-
- EL = '00'x /* HEX 00 separator between PCB file records */
-
- EachFile = READLN('PCBfiles')
-
- DO UNTIL EOF('PCBfiles')
- NameSize = SUBSTR(EachFile, 1, 37, " ")
- DateInfo = SUBSTR(EachFile, 38, 11, " ")
- TimeInfo = SUBSTR(EachFile, 49, 10)
-
- DateInfo = STRIP(DateInfo)
- PARSE VAR DateInfo DateNum'-'Month'-'Year
- DateInfo = RIGHT(Month DateNum' 19'Year, 11)
-
- CALL WRITECH('BOARDfiles', NameSize)
- CALL WRITECH('BOARDfiles', DateInfo)
- CALL WRITECH('BOARDfiles', TimeInfo)
- CALL WRITECH('BOARDfiles', EL)
- EachFile = READLN('PCBfiles')
- END
-
- CALL CLOSE('PCBfiles')
- CALL CLOSE('BOARDfiles')
-
- 'DELETE >NIL: T:PCBlist'
-
- SAY "Index file recreated in" PCBdir
- EXIT
-