home *** CD-ROM | disk | FTP | other *** search
/ Global Amiga Experience / globalamigaexperience.iso / graphic / cad / board_design / proboard_demo / rexx / mkboard.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-07-10  |  3.7 KB  |  131 lines

  1. /* MKBOARD.REXX: Construct Pro-Board's PCB index file, BOARD
  2.    $VER: MKBOARD V1.0                                              */
  3.  
  4. /* Written by Jeff Lindstrom ©1992 EP Systems                      */
  5.  
  6. address command
  7.  
  8. /* Add the Support Library if not already in the system            */
  9. IF ~SHOW('L', 'rexxsupport.library') THEN
  10.  CALL ADDLIB('rexxsupport.library',0,-30)
  11.  
  12. /* If no argument provided, first check for configuration file pcb.conf.
  13.      If pcb.conf not found, use current directory as PCB data directory. 
  14.    If argument is provided, check that it is a valid path.
  15. */
  16. IF ARG(1, 'Omitted') THEN
  17. DO
  18.   IF EXISTS('pcb.conf') THEN
  19.   DO
  20.     SAY 'Found configuration file pcb.conf'
  21.     IF ~(OPEN('DataDir','pcb.conf', 'r')) THEN
  22.     DO
  23.       SAY "Couldn't open the configuration file pcb.conf"
  24.       EXIT
  25.     END
  26.     
  27.     /* Get Data directory from pcb.conf */
  28.     PARSE VALUE STATEF('pcb.conf') WITH Type Size Other
  29.     PCBconf = READCH('DataDir', Size)
  30.     Len = INDEX(PCBconf, '00'x) - 1
  31.     PCBdir = SUBSTR(PCBconf, 1, Len)
  32.     SAY "PCB data directory set to" PCBdir
  33.     CALL CLOSE('DataDir')
  34.   END
  35.   ELSE  /* No configuration file; use current directory */
  36.   DO
  37.     'CD >T:CONFIGURATION'
  38.     'ECHO "Using current directory: " NOLINE'
  39.     'TYPE T:CONFIGURATION'
  40.     CALL OPEN('DataDir', 'T:CONFIGURATION', 'r')
  41.     PCBdir = READLN('DataDir')
  42.     
  43.     /* Last character must be a Directory or Subdirectory marker */
  44.     IF ~( (SUBSTR(PCBdir, LENGTH(PCBdir), 1)) = ':') THEN PCBdir = PCBdir || '/'
  45.     
  46.     CALL CLOSE('DataDir')
  47.     'DELETE >NIL: T:CONFIGURATION'
  48.   END
  49. END
  50. ELSE    /* Directory specified; correct format & verify existance */
  51. DO
  52.   PCBdir = ARG(1)
  53.   /* If no directory or sub-directory marker (':' or '/') is present,
  54.      add a directory marker to end of text.
  55.      This assumes that PCB data directory is not a sub-directory of
  56.      the current directory (which hasn't occurred in my experience).
  57.   */
  58.   IF ~(VERIFY(PCBdir, ':/')) THEN PCBdir = PCBdir || ':'
  59.   LastChar = (SUBSTR(PCBdir, LENGTH(PCBdir), 1))
  60.   /* If the last character is not ':' or '/', add '/' (the ':' would
  61.      already be in the body of the text.
  62.   */
  63.   IF ((INDEX(':/', LastChar)) = 0) THEN PCBdir = PCBdir || '/'
  64.   IF ~EXISTS(PCBdir) THEN
  65.   DO
  66.     SAY "Directory path doesn't exist."
  67.     EXIT
  68.   END
  69. END
  70.  
  71. /* Set clock ahead so dates are LISTed in the preferred format.   */
  72. /* Yeah, I KNOW this CAN cause problems in a multitasking system. */
  73. /* If you want to write the proper sub-routine, be my guest.      */
  74. 'DATE 01-Jan-00'
  75.  
  76. /* Read default directory */
  77. /* NOTE: Keep Quotes around PCBdir#?PCB so that
  78.    included spaces don't obstruct listing.
  79.    Also, sort the list alphabetically.
  80. */
  81. 'LIST TO T:PCBlist "'PCBdir'#?PCB" LFORMAT="%N %12L %17D %9T"'
  82. PARSE VALUE STATEF('T:PCBlist') WITH Type Size Other
  83. IF (Size = 0) THEN
  84. DO
  85.   SAY "No PCB data files in this directory."
  86.   'DELETE >NIL: T:PCBlist'
  87.   EXIT
  88. END
  89.  
  90. 'SORT T:PCBlist T:PCBlist'
  91.  
  92. /* Reset clock */
  93. 'SETCLOCK LOAD'
  94.  
  95. /* Reformat date string */
  96. CALL OPEN('PCBfiles', 'T:PCBlist', 'r')
  97.  
  98. IF ~(OPEN('BOARDfiles', PCBdir'BOARD', 'w')) THEN
  99. DO
  100.   SAY "Could not open PCB index file, "PCBdir"BOARD."
  101.   EXIT
  102. END
  103.  
  104. EL = '00'x   /* HEX 00 separator between PCB file records */
  105.  
  106. EachFile = READLN('PCBfiles')
  107.  
  108. DO UNTIL EOF('PCBfiles')
  109.   NameSize = SUBSTR(EachFile, 1, 37, " ")
  110.   DateInfo = SUBSTR(EachFile, 38, 11, " ")
  111.   TimeInfo = SUBSTR(EachFile, 49, 10)
  112.   
  113.   DateInfo = STRIP(DateInfo)
  114.   PARSE VAR DateInfo DateNum'-'Month'-'Year
  115.   DateInfo = RIGHT(Month DateNum' 19'Year, 11)
  116.  
  117.   CALL WRITECH('BOARDfiles', NameSize)
  118.   CALL WRITECH('BOARDfiles', DateInfo)
  119.   CALL WRITECH('BOARDfiles', TimeInfo)
  120.   CALL WRITECH('BOARDfiles', EL)
  121.   EachFile = READLN('PCBfiles')
  122. END
  123.  
  124. CALL CLOSE('PCBfiles')
  125. CALL CLOSE('BOARDfiles')
  126.  
  127. 'DELETE >NIL: T:PCBlist'
  128.  
  129. SAY "Index file recreated in" PCBdir
  130. EXIT
  131.