home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / ensmgr14.zip / ENS_MGRA.SCR < prev    next >
Text File  |  1994-07-24  |  22KB  |  797 lines

  1. ;  Terry Gildea     [70511,2530]                    FILE: ENS_MGRA.SCR
  2. ;
  3. ;  OFFLINE portion of ENS management scripts; requires ens_mgrz.scr.
  4. ;  Copyright (c) 1994 Terry L Gildea   Free redistribution authorized
  5. ;
  6. ;  Edit fields between * * * lines before EACH running of script!!
  7. ;
  8. ; +++keyword-flag+++  " %v   %d"     Requires OzCIS ver 2.0c(1)
  9. ;  Version " 1:4   24-Jul-94"
  10.  
  11.  
  12. ; *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
  13.  
  14.               ; name of existing folder to be Deleted
  15. define $DelName ""
  16.               ; name of existing folder to be Changed
  17. define $ChgName ""
  18.               ; name folder to Create; OR new name for existing folder
  19. define $NewName ""
  20.               ; expiration date in MM/DD/YY format
  21. define $expire  ""
  22.               ; number of days to retain clipped stories; max is 14
  23. define $retain  ""
  24.               ; wire services to add-ascending order, e.g. 5,19
  25. define $AddWire ""
  26.               ; wire services to delete-ascending order, e.g. 2,11
  27. define $DelWire ""
  28.               ; key phrases to delete-decending order, e.g. 5,2
  29. define $DelKey  ""
  30.               ; up to seven new/changed alphabetized key phrases
  31. define $key1 ""
  32. define $key2 ""
  33. define $key3 ""
  34. define $key4 ""
  35. define $key5 ""
  36. define $key6 ""
  37. define $key7 ""
  38. ; *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
  39.  
  40. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  41.    ;  CONFIGURATION OPTIONS; SEE DOCUMENTATION FOR DETAILS
  42.  
  43.    ; The variable $path MUST be the same in BOTH scripts!
  44. define $path     ""
  45. define $logfile  "ens_mgra.log"
  46.  
  47. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  48.    ;  THESE CONSTANTS MAY BE CHANGED BY COMPUSERVE IN THE FUTURE
  49.  
  50. define #BrkWire   18
  51. define #MaxWire   23
  52. define #MaxKey     7
  53. define #MaxRetain 14
  54. define #MaxName   10
  55. define #MaxFldrs   3
  56. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  57.  
  58.  
  59.  
  60. ;                            ENS_MGRA.SCR                  Page 1 of 13 
  61.  
  62. define #debug %false
  63. ;define #debug %true
  64.  
  65. define #maxDays
  66. define #moNbr
  67. define $moName
  68. define #expire_month
  69. define #expire_day
  70. define #expire_year
  71. define #current_month
  72. define #current_day
  73. define #current_year
  74. define #LoChgdKey
  75. define #HiChgdKey
  76. define $filename
  77. define $name
  78. define $key
  79. define $error
  80. define $select
  81. define #parentotl
  82.  
  83. timeout 0
  84. onerror  parse_error
  85. statline "Executing script ENS_MGR.SCR  (c) 1994"
  86.  
  87.   ; make sure user input strings are ok.
  88. upcase $DelName
  89. trim   $DelName
  90. upcase $NewName
  91. trim   $NewName
  92. upcase $ChgName
  93. trim   $ChgName
  94. upcase $expire
  95. trim   $expire
  96. upcase $retain
  97. trim   $retain
  98. upcase $AddWire
  99. trim   $AddWire
  100. upcase $DelWire
  101. trim   $DelWire
  102. upcase $DelKey
  103. trim   $DelKey
  104. upcase $key1
  105. trim   $key1
  106. upcase $key2
  107. trim   $key2
  108. upcase $key3
  109. trim   $key3
  110. upcase $key4
  111. trim   $key4
  112. upcase $key5
  113. trim   $key5
  114. upcase $key6
  115. trim   $key6
  116. upcase $key7
  117. trim   $key7
  118.  
  119.  
  120. ; Page 2 of 13               ENS_MGRA.SCR 
  121.  
  122.   ; find highest/lowest numbered key phrase change entered above
  123. set #HiChgdKey  0
  124. set #LoChgdKey  0
  125. if $key1 != ""   set #HiChgdKey  1
  126. if $key7 != ""   set #LoChgdKey  #MaxKey
  127. if $key2 != ""   set #HiChgdKey  2
  128. if $key6 != ""   set #LoChgdKey  6
  129. if $key3 != ""   set #HiChgdKey  3
  130. if $key5 != ""   set #LoChgdKey  5
  131. if $key4 != ""   set #HiChgdKey  4
  132. if $key4 != ""   set #LoChgdKey  4
  133. if $key5 != ""   set #HiChgdKey  5
  134. if $key3 != ""   set #LoChgdKey  3
  135. if $key6 != ""   set #HiChgdKey  6
  136. if $key2 != ""   set #LoChgdKey  2
  137. if $key7 != ""   set #HiChgdKey  #MaxKey
  138. if $key1 != ""   set #LoChgdKey  1
  139.  
  140.   ; perform check on data validity
  141. gosub valid_name
  142. set #1 1
  143. set $select $retain
  144. if $retain  != "" val #1 $retain
  145. if  #1 > #MaxRetain  set $error "Maximum retention of 14 days."
  146. if  #1 <  1          set $error "Retention period must be 1-14 days."
  147. if $error   != ""  goto  ckErr
  148. if $expire  != ""  gosub valid_date
  149. if $error   != ""  goto  ckErr
  150. if $DelKey  != ""  gosub valid_phrase
  151. if $error   != ""  goto  ckErr
  152. set $8 $AddWire
  153. if $AddWire != ""  gosub valid_wire
  154. if $error   != ""  goto  ckErr
  155. set $8 $DelWire
  156. if $DelWire != ""  gosub valid_wire
  157. if $error   != ""  goto  ckErr
  158. if $DelName != ""  goto  ckChg
  159. if $ChgName != ""  goto  ckChg
  160. if $NewName != ""  goto  ckNew
  161. set $error  "You MUST name a folder in one of Del/New/Chg fields."
  162. goto ckErr
  163.  
  164. ckChg:
  165.   if $ChgName  = ""        goto ckNew
  166.   set $error  "Can't change a folder after deleting it."
  167.   if $ChgName  = $DelName  goto ckErr
  168.   set $error "New name can't be same as Chg name."
  169.   if $NewName  = $ChgName  goto ckErr
  170.   set $error  "Chg option must specify at least one field to change."
  171.   if $NewName != ""       set $error ""
  172.   if $expire  != ""       set $error ""
  173.   if $retain  != ""       set $error ""
  174.   if $AddWire != $DelWire set $error ""
  175.   if $DelKey  != ""       set $error ""
  176.   if #HiChgdKey > 0       set $error ""
  177. goto ckErr
  178.  
  179.  
  180. ;                            ENS_MGRA.SCR                  Page 3 of 13 
  181.  
  182. ckNew:
  183.   set $error ""
  184.   if $NewName  = "" goto ckErr
  185.   if $NewName  = $ChgName set $error "New name can't equal Chg name."
  186.   if $NewName  = "" goto ckErr
  187.   if $expire   = "" set $error "New folder must have expiration date."
  188.   if $retain   = "" set $error "New folder must have retention period."
  189.   if $DelWire != "" set $error "Can't delete wires from a new folder."
  190.   if $DelKey  != "" set $error "Can't delete phrases from new folder."
  191.   if $AddWire  = "" set $error "New folder must specify wires to scan."
  192.   if #HiChgdKey = 0 set $error "New folder must specify a key phrase."
  193. ckErr:
  194. if $error = ""    gosub valid_paren
  195.  
  196.   ; Give the user one last chance
  197. cls
  198. if $error    = ""  gosub get_old
  199. if $DelName != ""  writeln "DEL: " $DelName
  200. if $ChgName != ""  writeln "CHG: " $ChgName
  201. if $NewName != ""  writeln "NEW: " $NewName
  202. if $expire  != ""  writeln "EXPIRE:  " $expire
  203. if $retain  != ""  writeln "RETAIN:  " $retain
  204. if $DelWire != ""  writeln "DEL-WIRES: " $DelWire
  205. if $AddWire != ""  writeln "ADD-WIRES: " $AddWire
  206. if $DelKey  != ""  writeln "DEL-KEYS:  " $DelKey
  207. if #LoChgdKey != 0 writeln "NEW/CHG KEYS:"
  208. if $key1 != "" writeln "1. " $key1
  209. if $key2 != "" writeln "2. " $key2
  210. if $key3 != "" writeln "3. " $key3
  211. if $key4 != "" writeln "4. " $key4
  212. if $key5 != "" writeln "5. " $key5
  213. if $key6 != "" writeln "6. " $key6
  214. if $key7 != "" writeln "7. " $key7
  215. writeln
  216. if $error != "" writeln "ERROR: " $error
  217.  
  218.  
  219. offline:
  220.   set $5 "N"
  221.   set $4 "Correct ERRORS before going online.  PRESS RETURN"
  222.   if $error  = "" set $4 "Save these data for online processing? (Y/N)"
  223.   prompt $5 $4
  224.   if $error != "" goto alldone
  225.   upcase $5
  226.   if $5 = "Y"     gosub write_result
  227. goto alldone
  228.  
  229.  
  230. alldone:
  231.   capture ON $logfile  /o
  232.   gosub record_data
  233.   cwrite  "Normal script termination offline. " %date "  " %time
  234.   capture OFF
  235. end
  236.  
  237.  
  238.  
  239.  
  240. ; Page 4 of 13               ENS_MGRA.SCR  
  241.  
  242.  
  243.  
  244. file_error:
  245.     capture ON $logfile  /o
  246.     writeln "File ERROR "  " on: " $filename " " $error
  247.     cwrite  "File ERROR "  " on: " $filename " " $error
  248.     capture OFF
  249. fail
  250.  
  251.  
  252. parse_error:
  253.     capture ON $logfile /o
  254.     writeln "ERROR parsing: " $1 " at " $select  " " #3
  255.     cwrite  "ERROR parsing: " $1 " at " $select  " " #3
  256.     gosub record_data
  257.     capture OFF
  258. fail
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  266. ; Subroutine to record the values of input data
  267. ;
  268. record_data:
  269.     if $DelName != ""  cwrite "DEL: " $DelName
  270.     if $ChgName != ""  cwrite "CHG: " $ChgName
  271.     if $NewName != ""  cwrite "NEW: " $NewName
  272.     if $expire  != ""  cwrite "EXPIRE:  " $expire
  273.     if $retain  != ""  cwrite "RETAIN:  " $retain
  274.     if $DelWire != ""  cwrite "DEL-WIRES: " $DelWire
  275.     if $AddWire != ""  cwrite "ADD-WIRES: " $AddWire
  276.     if $DelKey  != ""  cwrite "DEL-KEYS:  " $DelKey
  277.     if #LoChgdKey != 0 cwrite "NEW/CHG KEYS:"
  278.     if $key1 != "" cwrite "1. " $key1
  279.     if $key2 != "" cwrite "2. " $key2
  280.     if $key3 != "" cwrite "3. " $key3
  281.     if $key4 != "" cwrite "4. " $key4
  282.     if $key5 != "" cwrite "5. " $key5
  283.     if $key6 != "" cwrite "6. " $key6
  284.     if $key7 != "" cwrite "7. " $key7
  285.     cwrite %cr
  286.     if $error != "" cwrite "ERROR: " $error %cr
  287. return
  288. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300. ;                            ENS_MGRA.SCR                  Page 5 of 13 
  301.  
  302. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  303. ; Subroutine to check for valid expiration date
  304. ; Parameters:  $expire  -  the expiration date
  305. ; Returns:     $error   -  error message (null if no error)
  306. ;
  307. valid_date:
  308.     set $error "Date needs leading zero or delimiter. Use MM/DD/YY."
  309.     length #9  $expire
  310.     if  #9 != 8      return
  311.  
  312.     set $error "Invalid delimiter in date.  Use MM/DD/YY format."
  313.     pos #9 "/" $expire
  314.     if  #9 != 3      return
  315.     set $9 $expire
  316.     delstr $9 1 3 $8
  317.     midstr $9 1 2
  318.     pos #9 "/" $8
  319.     if  #9 != 3      return
  320.     val #9 $9
  321.     set $error "Month can't exceed 12.  Use MM/DD/YY format."
  322.     if #9 > 12       return
  323.  
  324.  
  325.     set $error ""
  326.     gosub valid_days
  327.     if $error != ""  return
  328.     set $error ""
  329. return
  330.  
  331.  
  332.  
  333.  
  334. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  335. ; Subroutine to check for valid input data in list of DelPhrase
  336. ; Parameters:   $DelKey  - list of phrase numbers to be deleted
  337. ;               #4       - integer value of parsed number
  338. ; Returns:      $error   - error message (null if no error)
  339. ;
  340. valid_phrase:
  341.     set #8 #MaxKey
  342.     set $1 $DelKey
  343.     vp_loop:
  344.         gosub parse
  345.         set $error "Highest possible del-key is only "  #MaxKey
  346.         if #4 > #MaxKey  goto end_vp
  347.         set $error "Deleted phrases MUST be listed in decending order."
  348.         if #4 > #8       goto end_vp
  349.         set #8 #4
  350.     if #3 != 0 goto vp_loop
  351.     set $error ""
  352. end_vp:
  353. return
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360. ; Page 6 of 13               ENS_MGRA.SCR  
  361.  
  362. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  363. ; Subroutine to check for valid input data in DelWire and AddWire
  364. ; Parameters:   $8      - either $DelWire or $AddWire
  365. ;               #4      - integer value of parsed number
  366. ; Returns:      $error  - error message (null if no error)
  367. ;
  368. valid_wire:
  369.     set #8 0
  370.     set $1 $8
  371.     if $error != "" goto end_vw
  372.     vw_loop:
  373.         gosub parse
  374.         set $error "Wire add/del MUST be listed in ascending order."
  375.         if  #4 < #8        goto end_vw
  376.         set $error "No wire service exists beyond " #MaxWire
  377.         if  #4 > #MaxWire  goto end_vw
  378.         set #8 #4
  379.     if #3 != 0   goto vw_loop
  380.     set $error ""
  381. end_vw:
  382. return
  383.  
  384.  
  385.  
  386. ;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  387. ; Subroutine to extract numbers from sequence in string variable
  388. ; Parameters:   $1      - string containing the remaining sequence
  389. ; Returns:      $select - string representation of next digits
  390. ;               #4      - integer representation of the number
  391. ;               #3      - equals 0 when no more numbers remain
  392. ;
  393. parse:
  394.       ; locate delimiter char in sequence of numbers
  395.     pos #1 ","  $1
  396.     set #3  #1
  397.     set $select $1
  398.  
  399.       ; if zero this is last number
  400.     if  #1 = 0 goto last_one
  401.     if #debug = %true cwrite %cr "Remaining parse of: " $1
  402.  
  403.       ; extract number from the input sequence
  404.     dec #1
  405.     midstr $1  1  #1  $select
  406.  
  407.       ; delete current number from the string
  408.     inc #1
  409.     delstr $1  1  #1
  410.  
  411.       ; check for error, a non-digit string
  412.     last_one:
  413.     val #4  $select
  414.     if #debug = %true cwrite "Returning from parse with # " $select
  415. return
  416.  
  417.  
  418.  
  419.  
  420. ;                            ENS_MGRA.SCR                  Page 7 of 13 
  421. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  422. ; Subroutine to call check routine for each name string
  423. ; Parameters:  $ChgName, $DelName, $NewName
  424. ; Returns:     $error   -  error message (null if no error)
  425. ;
  426. valid_name:
  427.     set $name $NewName
  428.     gosub ck_name
  429.     set $name $ChgName
  430.     if $error = "" gosub ck_name
  431.     set $name $DelName
  432.     if $error = "" gosub ck_name
  433. return
  434.  
  435. ck_name:
  436.     set $error $Name " Name can NOT contain imbedded spaces."
  437.     pos #1 " " $Name
  438.     if  #1 > 0  return
  439.     set $error $Name " Name exceeds " #MaxName " char in length."
  440.     length #1 $Name
  441.     if  #1 <= #MaxName  set $error ""
  442. return
  443.  
  444. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  445. ; Subroutine to record script test results in next available file.
  446. ; after checking existing data files for folder name duplication
  447. ;
  448. write_result:
  449.     set #1 1
  450.     name_loop:
  451.         set    $filename $path
  452.         concat $filename "newdata" #1 ".fix"
  453.         if not fexist $filename   goto write_OK
  454.         set    $name " "
  455.         concat $name $DelName " " $NewName " " $ChgName " "
  456.         fopen     &4 $filename
  457.         if ferror &4              goto file_error
  458.         freadln   &4 $1
  459.         posnc     #2 $1 $name
  460.         if #2 != 0                goto fnd_dupl
  461.         freadln   &4 $1
  462.         posnc     #2 $1 $name
  463.         if #2 != 0                goto fnd_dupl
  464.         freadln   &4 $1
  465.         posnc     #2 $1 $name
  466.         if #2 != 0                goto fnd_dupl
  467.         fclose &4
  468.         if ferror &4              goto file_error
  469.         inc #1
  470.     if #1 <= #MaxFldrs goto name_loop
  471.     goto end_wrtrst
  472.  
  473.     fnd_dupl:
  474.         fclose &4
  475.         set $5 "N"
  476.         prompt $5  "Data exists for folder: " $1 " OVERWRITE? (Y/N)"
  477.         upcase $5
  478.         if $5 != "Y"  goto alldone
  479.  
  480. ; Page 8 of 13               ENS_MGRA.SCR  
  481.  
  482.  
  483. write_OK:
  484.     set $error " File Open "
  485.     fcreate &1 $filename
  486.     if ferror &1 goto file_error
  487.     set $error " File Write "
  488.     fwrite &1   $DelName  %cr
  489.     fwrite &1   $ChgName  %cr
  490.     fwrite &1   $NewName  %cr
  491.     fwrite &1   $expire   %cr
  492.     fwrite &1   $retain   %cr
  493.     fwrite &1   $DelWire  %cr
  494.     fwrite &1   $AddWire  %cr
  495.     fwrite &1   $DelKey   %cr
  496.     fwrite &1   #LoChgdKey %cr
  497.     fwrite &1   #HiChgdKey %cr
  498.     fwrite &1   $key1   %cr
  499.     fwrite &1   $key2   %cr
  500.     fwrite &1   $key3   %cr
  501.     fwrite &1   $key4   %cr
  502.     fwrite &1   $key5   %cr
  503.     fwrite &1   $key6   %cr
  504.     fwrite &1   $key7   %cr
  505.     if ferror &1 goto file_error
  506.     set $error " File Close "
  507.     fclose &1
  508.     if ferror &1 goto file_error
  509.     set $error ""
  510.     writeln "Data stored in file: " $filename
  511.     cwrite  "Data stored in file: " $filename
  512. return
  513.  
  514.     end_wrtrst:
  515.     writeln "No more than " #MaxFldrs " files available."
  516. return
  517.  
  518.  
  519. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  520. ; Subroutine writes existing personal folder characteristics to screen
  521. ;
  522. get_old:
  523.     set    $filename $path
  524.     concat $filename $ChgName ".KEY"
  525.     if not fexist $filename  goto end_getold
  526.     fopen  &1 $filename
  527.     if ferror &1             goto file_error
  528.     set #2 0
  529.     get_loop:
  530.         freadln  &1 $1
  531.         inc #2
  532.         if #2 > 5 writeln $1
  533.     if not feof &1           goto get_loop
  534.     fclose &1
  535.     if ferror &1             goto file_error
  536. end_getold:
  537. return
  538.  
  539.  
  540. ;                            ENS_MGRA.SCR                  Page 9 of 13 
  541.  
  542. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  543. ; Subroutine to check for valid expiration date
  544. ; Parameters:  $expire  -  the expiration date
  545. ; Returns:     $error   -  error message (null if no error)
  546. ;
  547. valid_days:
  548.     cls
  549.     set $9 %date
  550.     midstr $9 1 2
  551.     val #current_day $9
  552.  
  553.     set $9 %date
  554.     midstr $9 4 3
  555.     set $moName $9
  556.     gosub moToNbr
  557.     set #current_month #moNbr
  558.  
  559.     set $9 %date
  560.     midstr $9 8 2
  561.     val #current_year $9
  562.  
  563.       ; extract year, month, day from $expire
  564.     set $9 $expire
  565.     midstr $9 7 2
  566.     val #9 $9
  567.     set #expire_year #9
  568.  
  569.     set $9 $expire
  570.     midstr $9 1 2
  571.     val #9 $9
  572.     set #expire_month #9
  573.  
  574.     set $9 $expire
  575.     midstr $9 4 2
  576.     val #9 $9
  577.     set #expire_day  #9
  578.  
  579.       ; get #maxDays, #moName for #expire_month - check they're legal
  580.     set   #moNbr #expire_month
  581.     gosub daysInMonth
  582.     gosub moToName
  583.     set $1 "Month of " $moName " has only " #maxDays " days."
  584.     if #9 > #maxDays  goto end_valid_days
  585.  
  586.  
  587.       ; check it's not a past date
  588.     set $1 "Expiration can't be a PAST date; it must be in the future."
  589.     if #expire_year   > #current_year   goto end_past
  590.     if #expire_year   < #current_year   goto end_valid_days
  591.  
  592.       ; in the current year check months
  593.     if #expire_month  > #current_month  goto end_past
  594.     if #expire_month  < #current_month  goto end_valid_days
  595.  
  596.       ; in the current month check the days
  597.     if #expire_day    < #current_day    goto end_valid_days
  598.   end_past:
  599.  
  600. ; Page 10 of 13              ENS_MGRA.SCR 
  601.  
  602.       ; check that expiration date is within the next year
  603.     set $1 "Expiration date can't be MORE than one year into future."
  604.     if #expire_year  = #current_year   goto end_future
  605.     inc #current_year
  606.     if #expire_year  > #current_year   goto end_valid_days
  607.  
  608.       ; expires sometime next year so check the month
  609.     if #expire_month < #current_month  goto end_future
  610.     if #expire_month > #current_month  goto end_valid_days
  611.  
  612.       ; finally in current month check days
  613.     if #expire_day   > #current_day    goto end_valid_days
  614.   end_future:
  615.     set $1 ""
  616.   end_valid_days:
  617.     set $error $1
  618. return
  619.  
  620. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  621. ; Subroutine to convert month alpha to month number
  622. ; Parameter:   $moName  -  month three letter alpha
  623. ; Returns:     #moNbr   -  month number
  624. ;
  625. moToNbr:
  626.     upcase $moName
  627.     if $moName = JAN set #moNbr 1
  628.     if $moName = FEB set #moNbr 2
  629.     if $moName = MAR set #moNbr 3
  630.     if $moName = APR set #moNbr 4
  631.     if $moName = MAY set #moNbr 5
  632.     if $moName = JUN set #moNbr 6
  633.     if $moName = JUL set #moNbr 7
  634.     if $moName = AUG set #moNbr 8
  635.     if $moName = SEP set #moNbr 9
  636.     if $moName = OCT set #moNbr 10
  637.     if $moName = NOV set #moNbr 11
  638.     if $moName = DEC set #moNbr 12
  639. return
  640.  
  641. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  642. ; Subroutine to convert month number to three letter alpha
  643. ; Parameter:   #moNbr   -  month number to be converted
  644. ; Returns:     $moName  -  month three letter alpha
  645. ;
  646. moToName:
  647.     if #moNbr = 1  set $moName "JAN"
  648.     if #moNbr = 2  set $moName "FEB"
  649.     if #moNbr = 3  set $moName "MAR"
  650.     if #moNbr = 4  set $moName "APR"
  651.     if #moNbr = 5  set $moName "MAY"
  652.     if #moNbr = 6  set $moName "JUN"
  653.     if #moNbr = 7  set $moName "JUL"
  654.     if #moNbr = 8  set $moName "AUG"
  655.     if #moNbr = 9  set $moName "SEP"
  656.     if #moNbr = 10 set $moName "OCT"
  657.     if #moNbr = 11 set $moName "NOV"
  658.     if #moNbr = 12 set $moName "DEC"
  659. return
  660. ;                            ENS_MGRA.SCR                 Page 11 of 13 
  661.  
  662. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  663. ; Subroutine to check for maximum number of days in a month
  664. ; Parameters:  #moNbr   -  month number to be checked
  665. ; Returns:     #maxDays -  the last day in this month
  666. ;
  667. daysInMonth:
  668.     set #maxDays 31
  669.     if #moNbr = 2  set #maxDays 28
  670.     if #moNbr = 9  set #maxDays 30
  671.     if #moNbr = 4  set #maxDays 30
  672.     if #moNbr = 6  set #maxDays 30
  673.     if #moNbr = 11 set #maxDays 30
  674. return
  675.  
  676.  
  677. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  678. ; Subroutine to call check routine for each key phrase string
  679. ; Parameters:  $key?    -  the set of seven key phrases
  680. ; Returns:     $error   -  error message (null if no error)
  681. ;
  682. valid_paren:
  683.     set $key $key1
  684.     gosub ck_paren
  685.     set $key $key2
  686.     gosub ck_paren
  687.     set $key $key3
  688.     gosub ck_paren
  689.     set $key $key4
  690.     gosub ck_paren
  691.     set $key $key5
  692.     gosub ck_paren
  693.     set $key $key6
  694.     gosub ck_paren
  695.     set $key $key7
  696.     gosub ck_paren
  697. return
  698. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720. ; Page 12 of 13              ENS_MGRA.SCR 
  721.  
  722. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  723. ; Subroutine to check for valid parenthesis matching
  724. ; Parameters:  $key     -  key phrase to test
  725. ; Returns:     $error   -  error message (null if no error)
  726. ;
  727. ck_paren:
  728.     if $key    = ""  return
  729.     if $error != ""  return
  730.     set $9 $key
  731.     length #3 $9
  732.     set #parentotl 0
  733.  
  734. lft_loop:
  735.     pos #1  "(" $9
  736.     pos #2  ")" $9
  737.     if  #1 = 0   set #1 #3
  738.     if  #2 = 0   set #2 #3
  739.     if  #2 < #1              gosub rht_loop
  740.     if  #2 = #1              goto end_paren
  741.     if  #parentotl < 0       goto end_paren
  742.     inc #parentotl
  743.     inc #1
  744.     length #3 $9
  745.     midstr $9 #1 #3 $9
  746. if  #1 != 1  goto lft_loop
  747. goto end_paren
  748.  
  749.     rht_loop:
  750.         pos #1  "(" $9
  751.         pos #2  ")" $9
  752.         if  #2 = 0   set #2 #3
  753.         if  #1 = 0   set #1 #3
  754.         if  #1 <= #2            return
  755.         dec #parentotl
  756.         if  #parentotl < 0      return
  757.         inc #2
  758.         length #3 $9
  759.         midstr $9 #2 #3 $9
  760.     if #2 != 1  goto rht_loop
  761. end_paren:
  762. if #parentotl != 0  set $error "Unmatched parenthesis: " $key
  763. return
  764.  
  765. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  766. ; Subroutine to record validation tests for debug use
  767. ;
  768. offline_test:
  769.     set    $1  "TESTDATA"
  770.     set    $filename $path
  771.     concat $filename $1 ".MGR"
  772.     capture ON   $filename
  773.     cwrite  "ens_mgr.scr TEST  " %date " at " %time "   OFFLINE"  %cr
  774.     gosub record_data
  775.     capture OFF ;$filename
  776. return
  777. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  778.  
  779. ;END OF FILE
  780. ;                            ENS_MGRA.SCR                 Page 13 of 13 
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.