home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / HILFEN / MODEM / COMAND28 / BBMAINT.CMD < prev    next >
OS/2 REXX Batch file  |  1993-12-01  |  8KB  |  225 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "BBS Maintenance ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND BBS file maintenance script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       The script, named BBSETUP.CMD, is executed to setup the BBS
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies (and creates) the subdirs to be
  12. ;    used.  This script, BBMAINT.CMD is used to update relevant files.
  13. ; -----------------------------------------------------------------------
  14. ;    NOTE: This script expects to find a file named BBSDAT on 1) the
  15. ;    current subdirectory, 2) The COM-AND= environment var specified
  16. ;    subdirectory, or 3) the subdirectory where THIS script resides.
  17. ;    If this file is found, it will be overwritten subsequently.  If
  18. ;    NOT found, BBSDAT will be created on the subdir where COM-AND=
  19. ;    points.  S29 is used to keep the file name (subroutine INIT).
  20. ; -----------------------------------------------------------------------
  21. ;    NOTE: This script expects to find subroutine scripts named:
  22. ;    BBMAINT1 through BBMAINT4 on the same subdir as this script!
  23. ; -----------------------------------------------------------------------
  24. ;
  25. ;    Establish a DWINDOW, and change the text display to window default.
  26. ;    .. Save the previous text display attribute, for restoration later.
  27. ;
  28.     DWIND 1,2 22,78     ; Establish scrolling region
  29.     N99 = "_TEXT"           ; Save original text attr
  30.     SET TEXT "_DEFA"        ; Set text attr
  31.     SET FLAG(9) OFF     ; Note if we did any saves
  32. ;
  33. ;    Perform tasks
  34. ;
  35.     GOSUB Init        ; Setup initial values
  36.     GOSUB Files        ; Paint main screen
  37. ;
  38. ;    Exit the script
  39. ;
  40. Escape:
  41. Exit:
  42.     SET TEXT N99        ; Reset text attr finally
  43.     DWINDOW CLEAR        ; Clear any scrolling region
  44.     CLEAR            ; Clear entire text window
  45.     EXIT
  46. ; -----------------------------------------------------------------------
  47. ; ----- Subroutine: Init ->  Set initial values from BBSDAT
  48. ;    .. NOTE: S29 returns the file name to use for writes to BBSDAT
  49. ;
  50. Init:
  51.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  52.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for BBS
  53.     S22 = "\BBS"            ; Set to our subdirectory
  54.     S23 = "\BBS\FILES"      ; Set subdir for files
  55.     S24 = "\BBS\MAIL"       ; Set subdir for mail
  56.     S25 = "\BBS\BULLETIN"   ; Set subdir for bulletins
  57. ;
  58. ;    Replace above values from BBSDAT, if that script exists
  59. ;
  60.     S29 = ""                ; Make value null
  61.     IF ISSC "BBSDAT"        ; If file exists on dft subdir or COM-AND=
  62.        FCALL "BBSDAT"       ; .. execute it
  63.     ELSE
  64.        S10 = "_SCRIPT"      ; Get current script fname
  65.        GOSUB Parse_Fname    ; Extract drive:Subdir from name
  66.        S10 = S10*"\BBSDAT"  ; Make new name
  67.        IF ISSC S10        ; Invoke it if its THERE
  68.           FCALL S10     ; Invoke it
  69.           S29 = S10     ; Save for later
  70.           ENDIF
  71.        ENDIF
  72.     RETURN            ; Done init
  73. ; -----------------------------------------------------------------------
  74. ;    Subroutine: Parse drive:subdirectory from file name
  75. ;
  76. ;    S10 passes fully qualified name S10 returns drive:subdirectory
  77. ;                    S11 returns file name
  78. ;    N10,N11 are scratch values
  79. ; -----------------------------------------------------------------------
  80. ;
  81. Parse_Fname:
  82.     LENGTH S10 N10            ; Find length of string
  83.     FOR N11 = (N10-1),0,-1        ; Scan backwards through string
  84.         IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
  85.         ENDFOR
  86.     S11 = S10            ; No drive or path
  87.     S10 = ""                        ; Return null drive:path spec
  88.     RETURN
  89. ;
  90. ;    Extract drive and path from name; N11 points to ":" or "\"
  91. ;
  92. PAFN100:
  93.     S11 = S10(N11+1:N10)        ; Extract name portion
  94.     IF STRCMP S10(N11:N11) "\" DEC N11
  95.     S10 = S10(0:N11)        ; Save ":", remove last "\"
  96.     RETURN
  97. ; -----------------------------------------------------------------------
  98. ; ----- Error:    Open a window, display a message, and wait for keypress
  99. ;    S0 passes the error message
  100. ;
  101. Error:
  102.     WOPEN 10,10,12,70 (cont) Err_Esc
  103.     ATSAY 10,12 (cont) " Error "
  104.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  105.     ATSAY 12,26 (cont) " Press any key to continue "
  106.     ;
  107.     ;    Wait a keypress
  108.     ;
  109.     KEYGET S0        ; Wait for any key
  110.     WCLOSE
  111. Err_Esc:
  112.     RETURN
  113. ; -----------------------------------------------------------------------
  114. ; ----- Subroutine: Files ->  Update BBS files
  115. ;
  116. Files:
  117.     WOPEN 0,0 23,79 (defa) Main_Esc
  118.     ATSAY 0,2 (defa)   " BBS Files "
  119.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  120. File100:
  121.     CLEAR
  122.     LOCATE 2,2
  123.     MESS " 1) Update BBS User file"
  124.     MESS " 2) Update BBS File directory"
  125.     MESS " 3) Update BBS Mail listing"
  126.     MESS " 4) Update BBS Bulletin listing"
  127.  
  128.     IF ISSCRIPT "BBSetup" MESS " 5) Setup the BBS (default values)"
  129.     IF ISSCRIPT "BBS"     MESS " 6) Invoke the BBS"
  130.  
  131.     MESS "__________________________________"
  132.     MESS " "
  133.     MESS "    User file       is: "*S22*"\BBS-User"
  134.     MESS "    Files directory is: "*S23*"\BBS-File"
  135.     MESS "    Mail listing    is: "*S24*"\BBS-Mail"
  136.     MESS "    Bulletin list   is: "*S25*"\BBS-Bull"
  137.     MESS "__________________________________"
  138.     MESS " "
  139.     MESS "Select item (carriage return = previous): "
  140. ;
  141. ;    Wait for a keypress
  142. ;
  143.     GET S0 1        ; Wait for it
  144.     SWITCH S0        ; Act according to keyget
  145.       CASE "1"
  146.            S0 = "BBMAINT1"  ; Invoke subsidiary - userids
  147.            GOSUB FCALL    ; Try to FCALL it
  148.            ENDCASE
  149.       CASE "2"
  150.            S0 = "BBMAINT2"  ; Invoke subsidiary - files
  151.            GOSUB FCALL    ; Try to FCALL it
  152.            ENDCASE
  153.       CASE "3"
  154.            S0 = "BBMAINT4"  ; Invoke subsidiary - mail
  155.            GOSUB FCALL    ; Try to FCALL it
  156.            ENDCASE
  157.       CASE "4"
  158.            S0 = "BBMAINT3"  ; Invoke subsidiary - bulletin
  159.            GOSUB FCALL    ; Try to FCALL it
  160.            ENDCASE
  161.       CASE "5"
  162.            IF ISSCRIPT "BBSetup"
  163.           WCLOSE          ; Close open window
  164.           SET TEXT N99          ; Reset text attr finally
  165.           DWINDOW CLEAR       ; Clear any scrolling region
  166.           CLEAR           ; Clear entire text window
  167.           EXECUTE "BBSetup"       ; Chain to it
  168.           ENDIF
  169.            ENDCASE
  170.       CASE "6"
  171.            IF ISSCRIPT "BBS"
  172.           WCLOSE          ; Close open window
  173.           SET TEXT N99          ; Reset text attr finally
  174.           DWINDOW CLEAR       ; Clear any scrolling region
  175.           CLEAR           ; Clear entire text window
  176.           EXECUTE "BBS"           ; Chain to it
  177.           ENDIF
  178.            ENDCASE
  179.       CASE "_NULL"          ; c/r alone is exit
  180.            WCLOSE        ; Close window...
  181.            RETURN        ; Leave Main routine
  182.            ENDCASE
  183.       DEFAULT        ; None of the above
  184.            SOUND 100,100    ; Bronx cheer
  185.            ENDCASE
  186.       ENDSWITCH
  187.     GOTO File100        ; Repaint screen and ask again
  188. ;
  189. ;    Escape during main
  190. ;
  191. Main_Esc:
  192.     S0 = ""                 ; Blank entry
  193.     RETURN            ; And execute it
  194. ; -----------------------------------------------------------------------
  195. ; ----- FCALL:    Open a script given a file name.  The script may be on
  196. ;    the current subdir, the COM-AND=subdir, OR on the same path as
  197. ;    this script itself.  S0 passes an UNqualified script name.
  198. ;
  199. FCALL:
  200.     IF NOT ISSCRIPT S0    ; If basic fname d.n.e as a script
  201.        S10 = "_SCRIPT"      ; get out OWN script file name fully qual
  202.        GOSUB Parse_Fname    ; Parse out path
  203.        S0 = S10&"\"*S0      ; Make new script file name
  204.        ENDIF
  205.  
  206.     IF ISSCRIPT S0        ; If result exists...
  207.        FCALL S0        ; Invoke subsidiary file
  208.        RETURN        ; and return to caller
  209.        ENDIF
  210. ;
  211. ;    Issue an error msg
  212. ;
  213.     WOPEN 10,10,13,70 (cont) FCALEsc
  214.     ATSAY 10,12 (cont) " BBMAINT "
  215.     ATSAY 11,12 (cont) " The script: "*S0
  216.     ATSAY 12,12 (cont) " cannot be found. "
  217.     ATSAY 13,26 (cont) " Press any key to continue "
  218.     ;
  219.     ;    Wait a keypress
  220.     ;
  221.     KEYGET S0        ; Wait for any key
  222.     WCLOSE
  223. FCALEsc:
  224.     RETURN
  225.