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

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "BBS Setup ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND BBS setup script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This 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.  The script BBMAINT is used to update related 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. ;
  22. ;    Establish a DWINDOW, and change the text display to window default.
  23. ;    .. Save the previous text display attribute, for restoration later.
  24. ;
  25.     DWIND 1,2 22,78     ; Establish scrolling region
  26.     N99 = "_TEXT"           ; Save original text attr
  27.     SET TEXT "_DEFA"        ; Set text attr
  28.     SET FLAG(9) OFF     ; Note if we did any saves
  29. ;
  30. ;    Perform tasks
  31. ;
  32.     GOSUB Init        ; Setup initial values
  33.     GOSUB Main        ; Paint main screen
  34. ;***    GOSUB ChkSave        ; Check if save needed
  35.     GOSUB ChkAll        ; Check if subd's exist
  36. ;
  37. ;    Exit the script
  38. ;
  39. Escape:
  40. Exit:
  41.     SET TEXT N99        ; Reset text attr finally
  42.     DWINDOW CLEAR        ; Clear any scrolling region
  43.     CLEAR            ; Clear entire text window
  44.     EXIT
  45. ; -----------------------------------------------------------------------
  46. ; ----- Subroutine: Init ->  Set initial values from BBSDAT
  47. ;    .. NOTE: S29 returns the file name to use for writes to BBSDAT
  48. ;
  49. Init:
  50.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  51.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for BBS
  52.     S22 = "\BBS"            ; Set to our subdirectory
  53.     S23 = "\BBS\FILES"      ; Set subdir for files
  54.     S24 = "\BBS\MAIL"       ; Set subdir for mail
  55.     S25 = "\BBS\BULLETIN"   ; Set subdir for bulletins
  56. ;
  57. ;    Replace above values from BBSDAT, if that script exists
  58. ;
  59.     S29 = ""                ; Make value null
  60.     IF ISSC "BBSDAT"        ; If file exists on dft subdir or COM-AND=
  61.        FCALL "BBSDAT"       ; .. execute it
  62.     ELSE
  63.        S10 = "_SCRIPT"      ; Get current script fname
  64.        GOSUB Parse_Fname    ; Extract drive:Subdir from name
  65.        S10 = S10*"\BBSDAT"  ; Make new name
  66.        IF ISSC S10        ; Invoke it if its THERE
  67.           FCALL S10     ; Invoke it
  68.           S29 = S10     ; Save for later
  69.           ENDIF
  70.        ENDIF
  71.     RETURN            ; Done init
  72. ; -----------------------------------------------------------------------
  73. ;    Subroutine: Parse drive:subdirectory from file name
  74. ;
  75. ;    S10 passes fully name        S10 returns drive:subdirectory
  76. ;                    S11 returns file name
  77. ;    N10,N11 are scratch values
  78. ; -----------------------------------------------------------------------
  79. ;
  80. Parse_Fname:
  81.     LENGTH S10 N10            ; Find length of string
  82.     FOR N11 = (N10-1),0,-1        ; Scan backwards through string
  83.         IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
  84.         ENDFOR
  85.     S11 = S10            ; No drive or path
  86.     S10 = ""                        ; Return null drive:path spec
  87.     RETURN
  88. ;
  89. ;    Extract drive and path from name; N11 points to ":" or "\"
  90. ;
  91. PAFN100:
  92.     S11 = S10(N11+1:N10)        ; Extract name portion
  93.     IF STRCMP S10(N11:N11) "\" DEC N11
  94.     S10 = S10(0:N11)        ; Save ":", remove last "\"
  95.     RETURN
  96. ; -----------------------------------------------------------------------
  97. ; ----- Subroutine: Save -> Save values in BBSDAT
  98. ;    .. BBSDAT is placed in dft subdir; create file if need be
  99. ;
  100. Save:
  101.     IF NULL S29        ; If INIT did not set a name
  102.     ;
  103.     ; Construct a file name on the appropriate directory
  104.     ;
  105.        S1 = ""              ; Initialize file name string
  106.        IF NOT ISFIL "BBSDAT"; If not on current subdir
  107.           ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
  108.           IF FOUND        ; If environment variable found
  109.          LENGTH S1 N0    ; Get its length
  110.          N0 = N0-1    ; Point to last char in string
  111.          IF not STRCMP S1(n0:n0) "\"
  112.             N0 = N0+1    ; Point after last char
  113.             CONCAT S1(n0) "\"
  114.             ENDIF
  115.          ENDIF
  116.           ENDIF
  117.        S1 = S1&"BBSDAT"     ; Add the necessary file name
  118.     ELSE S1 = S29        ; Else use name set by INIT
  119.     ;
  120.     ; Open the file, write the file, and close it
  121.     ;
  122.     FOPENO S1 TEXT        ; Open the file name so constructed
  123.     IF NOT SUCCESS
  124.        S0 = "Error opening BBSDAT file: "*S1
  125.        GOSUB Error        ; Report
  126.        RETURN        ; And we're done
  127.        ENDIF
  128.        S29 = "_OFILE"           ; Save file name we opened
  129.        ;
  130.        ; Write values we have as of now
  131.        ;
  132.     WRITE "; --- BBS initialization !" ; Write initial comments
  133.     WRITE ";     Updated "*"_DATE"*", at "*"_TIME"*"!"
  134.     WRITE ";!"                         ; Write initial comments
  135.  
  136.     WRITE "S20=`""*S20&"`"!"    ; Write port and speed
  137.     S0 = S21        ; Copy control string
  138.     PRESERVE S0        ; Make it printable
  139.     WRITE "S21=`""*S0&"`"!" ; Write modem control string
  140.     WRITE "S22=`""*S22&"`"!"; Write BBS subdir
  141.     WRITE "S23=`""*S23&"`"!"; Write BBS files subdir
  142.     WRITE "S24=`""*S24&"`"!"; Write BBS mail subdir
  143.     WRITE "S25=`""*S25&"`"!"; Write BBS bulletin subdir
  144.     WRITE "FRETURN!^Z "     ; Write end of file
  145.        ;
  146.        ; Close the file and we're done
  147.        ;
  148.     SET FLAG(9) ON        ; Note we did ONE save
  149.     FCLOSEO         ; Close the file
  150.     RETURN            ; And we're done
  151. ; -----------------------------------------------------------------------
  152. ; ----- Error:    Open a window, display a message, and wait for keypress
  153. ;    S0 passes the error message
  154. ;
  155. Error:
  156.     WOPEN 10,10,12,70 (cont) Err_Esc
  157.     ATSAY 10,12 (cont) " Error "
  158.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  159.     ATSAY 12,26 (cont) " Press any key to continue "
  160.     ;
  161.     ;    Wait a keypress
  162.     ;
  163.     KEYGET S0        ; Wait for any key
  164.     WCLOSE
  165. Err_Esc:
  166.     RETURN
  167. ; -----------------------------------------------------------------------
  168. ; ----- Subroutine: ChkSave ->    Save file?
  169. ;
  170. ChkSave:
  171.     IF FLAG(9) RETURN    ; At least one save was performed
  172.     WOPEN 0,0 23,79 (defa) Main_ESC
  173.     ATSAY 0,2 (defa)   " BBS Save "
  174.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  175. CHSA100:
  176.     CLEAR            ; Clear window
  177.     LOCATE 2,2
  178.     MESS " Do you wish to save the current values? (y/n) "
  179.     MESS "_______________________________________"
  180.     MESS " "
  181.     MESS "    Port and speed  is: "*S20
  182.     S0 = S21        ; Copy control string
  183.     PRESERVE S0        ; Make it printable
  184.     MESS "    Modem control   is: "*S0
  185.     MESS "    BBS main subdir is: "*S22
  186.     MESS "    Files subdir    is: "*S23
  187.     MESS "    Mail subdir     is: "*S24
  188.     MESS "    Bulletin subdir is: "*S25
  189.     MESS "_______________________________________"
  190.     MESS " "
  191.     MESS "Enter y or n (carriage return = n): "
  192. ;
  193. ;    Wait for a keypress
  194. ;
  195.     GET S0 1        ; Wait for it
  196.     IF NULL S0 GOTO CHSA200 ; If c/r, simply return
  197.     SWITCH S0        ; Act according to keyget
  198.       CASE "y"              ; Case insensitive
  199.            GOSUB Save
  200.            GOTO CHSA200
  201.            ENDCASE
  202.       CASE "n"              ; Case insensitive
  203.            GOTO CHSA200
  204.            ENDCASE
  205.       DEFAULT        ; None of the above
  206.            SOUND 100,100    ; Bronx cheer
  207.            ENDCASE
  208.       ENDSWITCH
  209.     GOTO CHSA100        ; Repaint screen and ask again
  210. ;
  211. ;    Exit, closing the window
  212. ;
  213. CHSA200:
  214.     WCLOSE
  215.     RETURN
  216. ; -----------------------------------------------------------------------
  217. ; ----- Subroutine: ChkAll ->  Check for subdir creation req'd
  218. ;
  219. ChkAll:
  220.     WOPEN 10,10 12,70 (cont)
  221.     ATSAY 10,12 (cont)   " BBS Subdirs "
  222.     ATSAY 11,12 (cont) " Checking existance of subdirs... "
  223.     PAUSE 1         ; Make it visible
  224. ;
  225. ;    Test for the existence of all subdirectories
  226. ;
  227.     SET FLAG(0) ON
  228.     FFIRST S22&"\*.*"       ; test for Main subd
  229.     IF SUCCESS SET FLAG(0) OFF
  230.  
  231.     SET FLAG(1) ON
  232.     FFIRST S23&"\*.*"       ; test for File subd
  233.     IF SUCCESS SET FLAG(1) OFF
  234.  
  235.     SET FLAG(2) ON
  236.     FFIRST S24&"\*.*"       ; test for Mail subd
  237.     IF SUCCESS SET FLAG(2) OFF
  238.  
  239.     SET FLAG(3) ON
  240.     FFIRST S25&"\*.*"       ; test for Main subd
  241.     IF SUCCESS SET FLAG(3) OFF
  242.  
  243.     WCLOSE            ; Close window we opened
  244.     IF NOT (FLAG(0) or FLAG(1) or FLAG(2) or FLAG(3)) RETURN
  245. ;
  246. ;    Ask if we're to create subdirs
  247. ;
  248.     WOPEN 0,0 23,79 (defa) Main_ESC
  249.     ATSAY 0,2 (defa)   " BBS Subdirs "
  250.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  251. CHAL100:
  252.     CLEAR            ; Clear window
  253.     LOCATE 2,2
  254.  
  255.     IF FLAG(0) MESS S22&" does not exist"
  256.     IF FLAG(1) MESS S23&" does not exist"
  257.     IF FLAG(2) MESS S24&" does not exist"
  258.     IF FLAG(3) MESS S25&" does not exist"
  259.     MESS " "                ; Blank separator
  260.     MESS " Do you wish to create the missing subdirs? (y/n) "
  261.     MESS "_______________________________________"
  262.     MESS " "
  263.     MESS "Enter y or n (carriage return = n): "
  264. ;
  265. ;    Wait for a keypress
  266. ;
  267.     GET S0 1        ; Wait for it
  268.     IF NULL S0 GOTO CHAL200 ; If c/r, simply return
  269.     SWITCH S0        ; Act according to keyget
  270.       CASE "y"              ; Case insensitive
  271.            GOSUB CreateSd
  272.            GOTO CHAL200
  273.            ENDCASE
  274.       CASE "n"              ; Case insensitive
  275.            GOTO CHAL200
  276.            ENDCASE
  277.       DEFAULT        ; None of the above
  278.            SOUND 100,100    ; Bronx cheer
  279.            ENDCASE
  280.       ENDSWITCH
  281.     GOTO CHAL100        ; Repaint screen and ask again
  282. ;
  283. ;    Exit, closing the window
  284. ;
  285. CHAL200:
  286.     WCLOSE
  287.     RETURN
  288. ; -----------------------------------------------------------------------
  289. ; ----- Subroutine: Main ->  main menu
  290. ;
  291. Main:
  292.     WOPEN 0,0 23,79 (defa) Main_ESC
  293.     ATSAY 0,2 (defa)   " BBS Setup "
  294.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  295. Main100:
  296.     CLEAR            ; Clear window
  297.     LOCATE 2,2
  298.     MESS " 1) Identify subdirectories used by BBS;      Do this 1st!!"
  299.     MESS " 2) Create BBS subdirectories and files;      Do this 2nd!!"
  300.     MESS " 3) Identify modem values;                    Finally..."
  301.  
  302.     IF ISSCRIPT "BBMaint" MESS " 4) Invoke maintenance script"
  303.     IF ISSCRIPT "BBS"     MESS " 5) Invoke the BBS"
  304.  
  305.     MESS "_______________________________________"
  306.     MESS " "
  307.     MESS "    Port and speed  is: "*S20
  308.     S0 = S21        ; Copy control string
  309.     PRESERVE S0        ; Make it printable
  310.     MESS "    Modem control   is: "*S0
  311.     MESS "    BBS main subdir is: "*S22
  312.     MESS "    Files subdir    is: "*S23
  313.     MESS "    Mail subdir     is: "*S24
  314.     MESS "    Bulletin subdir is: "*S25
  315.     MESS "_______________________________________"
  316.     MESS " "
  317.     MESS "BBSMAINT is used to update files once you have SETUP"
  318.     MESS "_______________________________________"
  319.     MESS " "
  320.     MESS "Select item (carriage return = exit): "
  321. ;
  322. ;    Wait for a keypress
  323. ;
  324.     GET S0 1        ; Wait for it
  325.     SWITCH S0        ; Act according to keyget
  326.       CASE "1"
  327.            GOSUB Subdirs
  328.            ENDCASE
  329.       CASE "2"
  330.            GOSUB ChkAll
  331.            ENDCASE
  332.       CASE "3"
  333.            GOSUB Modem
  334.            ENDCASE
  335.       CASE "4"
  336.            IF ISSCRIPT "BBMaint"
  337.           WCLOSE          ; Close open window
  338.           SET TEXT N99          ; Reset text attr finally
  339.           DWINDOW CLEAR       ; Clear any scrolling region
  340.           CLEAR           ; Clear entire text window
  341.           EXECUTE "BBMaint"       ; Chain to it
  342.           ENDIF
  343.            ENDCASE
  344.       CASE "5"
  345.            IF ISSCRIPT "BBS"
  346.           WCLOSE          ; Close open window
  347.           SET TEXT N99          ; Reset text attr finally
  348.           DWINDOW CLEAR       ; Clear any scrolling region
  349.           CLEAR           ; Clear entire text window
  350.           EXECUTE "BBS"           ; Chain to it
  351.           ENDIF
  352.            ENDCASE
  353.       CASE "_NULL"          ; c/r alone is exit
  354.            WCLOSE        ; Close window...
  355.            RETURN        ; Leave Main routine
  356.            ENDCASE
  357.       DEFAULT        ; None of the above
  358.            SOUND 100,100    ; Bronx cheer
  359.            ENDCASE
  360.       ENDSWITCH
  361.     GOTO Main100        ; Repaint screen and ask again
  362. ; -----------------------------------------------------------------------
  363. ; ----- Subroutine: Modem ->  modem values
  364. ;
  365. Modem:
  366.     WOPEN 0,0 23,79 (defa) Main_ESC
  367.     ATSAY 0,2 (defa)   " BBS Modem "
  368.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  369. MODE100:
  370.     CLEAR            ; Clear window
  371.     LOCATE 2,2
  372.     MESS " 1) Identify modem port"
  373.     MESS " 2) Identify modem speed"
  374.     MESS " 3) Identify modem control string"
  375.     MESS "_______________________________________"
  376.     MESS " "
  377.     MESS "    Port and speed  is: "*S20
  378.     S0 = S21        ; Copy control string
  379.     PRESERVE S0        ; Make it printable
  380.     MESS "    Modem control   is: "*S0
  381.     MESS "_______________________________________"
  382.     MESS " "
  383.     MESS "Select item (carriage return = previous): "
  384. ;
  385. ;    Wait for a keypress
  386. ;
  387.     GET S0 1        ; Wait for it
  388.     SWITCH S0        ; Act according to keyget
  389.       CASE "1"
  390.            GOSUB Modem_Port
  391.            ENDCASE
  392.       CASE "2"
  393.            GOSUB Modem_Speed
  394.            ENDCASE
  395.       CASE "3"
  396.            GOSUB Modem_Control
  397.            ENDCASE
  398.       CASE "_NULL"          ; c/r alone is exit
  399.            WCLOSE        ; Close window...
  400.            RETURN        ; Leave Main routine
  401.            ENDCASE
  402.       DEFAULT        ; None of the above
  403.            SOUND 100,100    ; Bronx cheer
  404.            ENDCASE
  405.       ENDSWITCH
  406.     GOTO MODE100        ; Repaint screen and ask again
  407. ;
  408. ;    Escape during main
  409. ;
  410. Main_Esc:
  411.     S0 = ""                 ; Blank entry
  412.     RETURN            ; And execute it
  413. ;
  414. ; ----- Subroutine: Modem_port -> Set default modem port to use
  415. ;
  416. Modem_Port:
  417.     WOPEN 0,0 23,79 (defa) Main_ESC
  418.     ATSAY 0,2 (defa)   " BBS Port "
  419.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  420.     LOCATE 2,2
  421.  
  422.     MESS "The BBS is currently directed to run on the port: "*S20(0:3)
  423.     MESS " "
  424.     MESS "The BBS may use any port COM1 through COM4.  If you wish to use a port other"
  425.     MESS "than the above, enter it here."
  426.     MESS " "
  427.     MESS "Port (carriage rtn alone accepts): "
  428. ;
  429. ;    Wait for entry, and interpret
  430. ;
  431.     S0 = "    "             ; Default value
  432.     GET S0 4        ; Wait for a char
  433.     IF NULL S0 GOTO MOPOEND ; Nothing entered
  434.     IF NOT FIND S0(0:2) "com" GOTO MOPOERR
  435.     IF S0(3) LT 1 or S0(3) GT 4 GOTO MOPOERR
  436. ;
  437. ;    Save the value
  438. ;
  439.     S20(0:3) = S0        ; Set new value
  440.     GOSUB Save        ; Save the new value
  441. ;
  442. ;    End of window
  443. ;
  444. MOPOEND:
  445.     WCLOSE
  446.     RETURN
  447. ;
  448. ;    Error in input string
  449. ;
  450. MOPOERR:
  451.     SOUND 100,100        ; Bronx cheer
  452.     GOTO Modem_Port     ; And try again
  453. ;
  454. ; ----- Subroutine: Modem_Speed -> Set default modem speed to use
  455. ;
  456. Modem_Speed:
  457.     WOPEN 0,0 23,79 (defa) Main_Esc
  458.     ATSAY 0,2 (defa)   " BBS Speed "
  459.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  460.     LOCATE 2,2
  461.  
  462.     MESS "The BBS currently defaults to wait for call at: "*S20(5:8)*" baud"
  463.     MESS " "
  464.     MESS "The BBS may wait for a call at any rate you wish.  If you wish to use a "
  465.     MESS "speed other than the above, enter it here. Legitimate speeds are: 300,"
  466.     MESS "1200, 2400, 4800, 9600, and 19.2"
  467.     MESS " "
  468.     MESS "Speed (carriage rtn alone accepts): "
  469. ;
  470. ;    Wait for entry, and interpret
  471. ;
  472.     S0 = "    "             ; Default value
  473.     GET S0 4        ; Wait for a char
  474.     IF NULL S0 GOTO MOSPEND ; Nothing entered
  475.     IF NOT FIND "300  300120024004800960019.2" S0(0:2) N0 GOTO MOSPERR
  476.     IF 4*(N0/4) ne N0 GOTO MOSPERR
  477. ;
  478. ;    Save the value
  479. ;
  480.     S20(5:8) = S0        ; Set new value
  481.     GOSUB Save        ; Save the new value
  482. ;
  483. ;    End of window
  484. ;
  485. MOSPEND:
  486.     WCLOSE
  487.     RETURN
  488. ;
  489. ;    Error in input string
  490. ;
  491. MOSPERR:
  492.     SOUND 100,100        ; Bronx cheer
  493.     GOTO Modem_Speed    ; And try again
  494. ;
  495. ; ----- Subroutine: Modem_Control -> Set the modem initialization string to use
  496. ;
  497. Modem_Control:
  498.     WOPEN 0,0 23,79 (defa) Main_Esc
  499.     ATSAY 0,2 (defa)   " BBS Control "
  500.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  501.     LOCATE 2,2
  502.  
  503.     MESS "The BBS currently is set to initialize the modem with: "
  504.     S0 = S21        ; Fetch value
  505.     PRESERVE S0        ; Preserve for printing
  506.     MESS S0         ; Display string
  507.     MESS " "
  508.     MESS "The initialization string must be correct for your modem.  Please refer to "
  509.     MESS "the documentation that came with your modem.  The init string will probably"
  510.     MESS "begin with modem attention (defa 'AT'), MUST enable autoanswer, and will"
  511.     MESS "probably end with a carriage return.  "
  512.     MESS " "
  513.     MESS "Please note: Enter '^^A' through '^^Z' to indicate control chars, '^^^^ for'"
  514.     MESS "a single caret, '!!' for a carriage return (or '^^M') and '!!!!' for a single"
  515.     MESS "exclamation point."
  516.     MESS " "
  517.     MESS "Control string (carriage return accepts): "
  518. ;
  519. ;    Wait for entry, and interpret
  520. ;
  521.     S0 = "    "             ; Default value
  522.     GET S0 50        ; Wait for a char
  523.     IF NULL S0 GOTO MOCOEND ; Nothing entered
  524. ;
  525. ;    Save the value
  526. ;
  527.     S21 = S0        ; Set new value
  528.     GOSUB Save        ; Save the new value
  529. ;
  530. ;    End of window
  531. ;
  532. MOCOEND:
  533.     WCLOSE
  534.     RETURN
  535. ; -----------------------------------------------------------------------
  536. ; ----- Subroutine: CreateSd -> Create subdirectories
  537. ;    .. Flags 0-3 control
  538. ;
  539. CreateSd:
  540.     IF FLAG(0)        ; Main subd does not exist
  541.        S0 = S22        ; Set-up passed parm
  542.        GOSUB Create     ; Attempt to create it
  543.        GOSUB NewUser    ; Create needed file (if d.n.e)
  544.        ENDIF
  545.  
  546.     IF FLAG(1)        ; File subd does not exist
  547.        S0 = S23        ; Set-up passed parm
  548.        GOSUB Create     ; Attempt to create it
  549.        GOSUB NewFile    ; Create needed file (if d.n.e)
  550.        ENDIF
  551.  
  552.     IF FLAG(2)        ; Mail subd does not exist
  553.        S0 = S24        ; Set-up passed parm
  554.        GOSUB Create     ; Attempt to create it
  555.        GOSUB NewMail    ; Create needed file (if d.n.e)
  556.        ENDIF
  557.  
  558.     IF FLAG(3)        ; Bulletin subd does not exist
  559.        S0 = S25        ; Set-up passed parm
  560.        GOSUB Create     ; Attempt to create it
  561.        GOSUB NewBull    ; Create needed file (if d.n.e)
  562.        ENDIF
  563.     RETURN
  564. ;
  565. ; ----- Subroutine: CheckSd -> Create an subdirectories
  566. ;    .. Flags 0-3 control
  567. ;
  568. CheckSd:
  569.     FFIRST S0&"\*.*"        ; Test for existence of subdir
  570.     IF SUCCESS RETURN    ; Return if it exists
  571.     GOSUB Create        ; Attempt to create it
  572.     RETURN
  573. ;
  574. ; ----- Subroutine: Create -> Create a subdirectory
  575. ;    .. S0 passes the subdirectory to create
  576. ;
  577. Create:
  578.     MDIR S0         ; Attempt to create subdir
  579.     IF FAILURE        ; Set-up passed parm
  580.        S0 = "Error creating: "*S0
  581.        GOSUB Error        ; Report the error
  582.        SET SUCCESS OFF    ; Return FAILED condition
  583.        ENDIF
  584.     RETURN
  585. ;
  586. ; ----- Subroutine: NewUser -> Create a new BBS-User file
  587. ;
  588. NewUser:
  589.     IF ISFILE S22&"\BBS-User" RETURN
  590.     FOPENO S22&"\BBS-User" TEXT
  591.     IF NOT SUCCESS        ; Open failed
  592.        S0 = "Error creating: "*S22&"\BBS-User"
  593.        GOSUB Error        ; Report
  594.        RETURN        ; And we're done
  595.        ENDIF
  596.     WRITE "!^Z"             ; Make it empty
  597.     FCLOSEO         ; Done with it
  598.     RETURN
  599. ;
  600. ; ----- Subroutine: NewFile -> Create a new BBS-File file
  601. ;
  602. NewFile:
  603.     IF ISFILE S23&"\BBS-File" RETURN
  604.     FOPENO S23&"\BBS-File" TEXT
  605.     IF NOT SUCCESS        ; Open failed
  606.        S0 = "Error creating: "*S23&"\BBS-File"
  607.        GOSUB Error        ; Report
  608.        RETURN        ; And we're done
  609.        ENDIF
  610.     WRITE "!^Z"             ; Make it empty
  611.     FCLOSEO         ; Done with it
  612.     RETURN
  613. ;
  614. ; ----- Subroutine: NewMail -> Create a new BBS-Mail file
  615. ;
  616. NewMail:
  617.     IF ISFILE S24&"\BBS-Mail" RETURN
  618.     FOPENO S24&"\BBS-Mail" TEXT
  619.     IF NOT SUCCESS        ; Open failed
  620.        S0 = "Error creating: "*S24&"\BBS-Mail"
  621.        GOSUB Error        ; Report
  622.        RETURN        ; And we're done
  623.        ENDIF
  624.     WRITE "!^Z"             ; Make it empty
  625.     FCLOSEO         ; Done with it
  626.     RETURN
  627. ;
  628. ; ----- Subroutine: NewBull -> Create a new BBS-Bull file
  629. ;
  630. NewBull:
  631.     IF ISFILE S25&"\BBS-Bull" RETURN
  632.     FOPENO S25&"\BBS-Bull" TEXT
  633.     IF NOT SUCCESS        ; Open failed
  634.        S0 = "Error creating: "*S25&"\BBS-Bull"
  635.        GOSUB Error        ; Report
  636.        RETURN        ; And we're done
  637.        ENDIF
  638.     WRITE "!^Z"             ; Make it empty
  639.     FCLOSEO         ; Done with it
  640.     RETURN
  641. ; -----------------------------------------------------------------------
  642. ; ----- Subroutine: NewDat ->  Ask if a new BBSDAT file is to be placed?
  643. ;
  644. NewDat:
  645.     IF NULL S29 AND NOT ISSC "BBSDAT" RETURN
  646.     WOPEN 0,0 23,79 (defa) Main_ESC
  647.     ATSAY 0,2 (defa)   " BBS Subdirs "
  648.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  649. NEDA100:
  650.     CLEAR            ; Clear window
  651.     LOCATE 2,2
  652.     MESS "Do you wish to place BBSDAT on the new BBS main subdirectory? (y/n) "
  653.     MESS "_______________________________________"
  654.     MESS " "
  655.     IF NOT NULL S29
  656.        MESS "BBSDAT is currently: "*S29
  657.     ELSE
  658.        S0 = "_SUBD"&"\BBSDAT"
  659.        IF NOT ISFILE "BBSDAT"
  660.           ENVIRON S0 "COM-AND="; Look for COM-AND= environment var
  661.           IF FOUND        ; If environment variable found
  662.          LENGTH S0 N0    ; Get its length
  663.          N0 = N0-1    ; Point to last char in string
  664.          IF STRCMP S0(n0:n0) "\" S0(n0:n0) = ""
  665.          S0 = S0&"\BBSDAT"
  666.          ENDIF
  667.           ENDIF
  668.        IF ISFILE S0
  669.           MESS "BBSDAT is now: "*S0
  670.        ELSE
  671.           MESS "BBSDAT would be: "*S0
  672.           ENDIF
  673.        ENDIF
  674.     MESS "_______________________________________"
  675.     MESS " "
  676.     MESS "Enter y or n (carriage return = y): "
  677. ;
  678. ;    Wait for a keypress
  679. ;
  680.     GET S0 1        ; Wait for it
  681.     IF NULL S0 GOTO NEDA200 ; If c/r, simply accept
  682.     SWITCH S0        ; Act according to keyget
  683.       CASE "y"              ; Case insensitive
  684.            GOTO NEDA200
  685.            ENDCASE
  686.       CASE "n"              ; Case insensitive
  687.            WCLOSE        ; DO nothing
  688.            RETURN
  689.            ENDCASE
  690.       DEFAULT        ; None of the above
  691.            SOUND 100,100    ; Bronx cheer
  692.            ENDCASE
  693.       ENDSWITCH
  694.     GOTO NEDA100        ; Repaint screen and ask again
  695. ;
  696. ;    Construct the other subdir names
  697. ;
  698. NEDA200:
  699.     S29 = S22&"\BBSDAT"
  700.     WCLOSE
  701.     RETURN
  702. ; -----------------------------------------------------------------------
  703. ; ----- Subroutine: DftSds ->  Main subdir changed - default the others?
  704. ;
  705. DftSds:
  706.     WOPEN 0,0 23,79 (defa) Main_ESC
  707.     ATSAY 0,2 (defa)   " BBS Subdirs "
  708.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  709. DFSD100:
  710.     CLEAR            ; Clear window
  711.     LOCATE 2,2
  712.     MESS " Do you wish to use the new main subdir as the root for others? (y/n) "
  713.     MESS "_______________________________________"
  714.     MESS " "
  715.     MESS "    BBS main subdir is now:   "*S22
  716.     MESS "    Files subdir WOULD be:    "*S22&"\Files"
  717.     MESS "    Mail subdir WOULD be:     "*S22&"\Mail"
  718.     MESS "    Bulletin subdir WOULD be: "*S22&"\Bulletin"
  719.     MESS "_______________________________________"
  720.     MESS " "
  721.     MESS "Enter y or n (carriage return = y): "
  722. ;
  723. ;    Wait for a keypress
  724. ;
  725.     GET S0 1        ; Wait for it
  726.     IF NULL S0 GOTO DFSD200 ; If c/r, simply accept
  727.     SWITCH S0        ; Act according to keyget
  728.       CASE "y"              ; Case insensitive
  729.            GOTO DFSD200
  730.            ENDCASE
  731.       CASE "n"              ; Case insensitive
  732.            WCLOSE        ; DO nothing
  733.            RETURN
  734.            ENDCASE
  735.       DEFAULT        ; None of the above
  736.            SOUND 100,100    ; Bronx cheer
  737.            ENDCASE
  738.       ENDSWITCH
  739.     GOTO DFSD100        ; Repaint screen and ask again
  740. ;
  741. ;    Construct the other subdir names
  742. ;
  743. DFSD200:
  744.     S23 = S22&"\Files"
  745.     S24 = S22&"\Mail"
  746.     S25 = S22&"\Bulletin"
  747.     WCLOSE
  748.     RETURN
  749. ; -----------------------------------------------------------------------
  750. ; ----- Subroutine: Subdirs ->    Update subdirectories used by BBS
  751. ;
  752. Subdirs:
  753.     WOPEN 0,0 23,79 (defa) Main_Esc
  754.     ATSAY 0,2 (defa)   " BBS Subdirs "
  755.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  756. SUBD100:
  757.     CLEAR
  758.     LOCATE 2,2
  759.     MESS " 1) Identify BBS main subdir"
  760.     MESS " 2) Identify BBS Files subdir"
  761.     MESS " 3) Identify BBS Mail subdir"
  762.     MESS " 4) Identify BBS Bulletins subdir"
  763.  
  764.     MESS "__________________________________"
  765.     MESS " "
  766.     MESS "    Main subdir     is: "*S22
  767.     MESS "    Files subdir    is: "*S23
  768.     MESS "    Mail subdir     is: "*S24
  769.     MESS "    Bulletin subdir is: "*S25
  770.     MESS "__________________________________"
  771.     MESS " "
  772.     MESS "Select item (carriage return = previous): "
  773. ;
  774. ;    Wait for a keypress
  775. ;
  776.     GET S0 1        ; Wait for it
  777.     SWITCH S0        ; Act according to keyget
  778.       CASE "1"
  779.            GOSUB MainSd
  780.            ENDCASE
  781.       CASE "2"
  782.            GOSUB FileSd
  783.            ENDCASE
  784.       CASE "3"
  785.            GOSUB MailSd
  786.            ENDCASE
  787.       CASE "4"
  788.            GOSUB BullSd
  789.            ENDCASE
  790.       CASE "_NULL"          ; c/r alone is exit
  791.            WCLOSE        ; Close window...
  792.            RETURN        ; Leave Main routine
  793.            ENDCASE
  794.       DEFAULT        ; None of the above
  795.            SOUND 100,100    ; Bronx cheer
  796.            ENDCASE
  797.       ENDSWITCH
  798.     GOTO Subd100        ; Repaint screen and ask again
  799. ;
  800. ; ----- Subroutine: MainSd -> Set the main subdirectory
  801. ;
  802. MainSd:
  803.     WOPEN 0,0 23,79 (defa) Main_Esc
  804.     ATSAY 0,2 (defa)   " BBS Main Subdir "
  805.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  806.     LOCATE 2,2
  807.  
  808.     MESS "The BBS main subdirectory is: "
  809.     MESS S22
  810.     MESS " "
  811.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  812.     MESS "contain at least one file (BBS-User).  The user ID file (BBS-User) residing"
  813.     MESS "there may be updated with from the main menu of this script."
  814.     MESS " "
  815.     MESS "BBS Main subdir (carriage return accepts): "
  816. ;
  817. ;    Wait for entry, and interpret
  818. ;
  819.     S0 = "    "             ; Default value
  820.     GET S0 50        ; Wait for a char
  821.     IF NULL S0 GOTO MASDEND ; Nothing entered
  822.     GOSUB CheckSd        ; Test for create needed
  823.     IF FAILED GOTO MASDEND    ; Skip if create failed
  824. ;
  825. ;    Save the value
  826. ;
  827.     S22 = S0        ; Set new value
  828.     GOSUB NewUser        ; Create needed file (if d.n.e)
  829.     GOSUB DftSds        ; Ask if we're to default the other subdirs
  830.     GOSUB NewDat        ; Ask if a new BBSDAT to be used
  831.     GOSUB Save        ; Save the new value
  832. ;
  833. ;    End of window
  834. ;
  835. MASDEND:
  836.     WCLOSE
  837.     RETURN
  838. ;
  839. ; ----- Subroutine: FileSd -> Set the file subdirectory
  840. ;
  841. FileSd:
  842.     WOPEN 0,0 23,79 (defa) Main_Esc
  843.     ATSAY 0,2 (defa)   " BBS File Subdir "
  844.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  845.     LOCATE 2,2
  846.  
  847.     MESS "The BBS file subdirectory is: "
  848.     MESS S23
  849.     MESS " "
  850.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  851.     MESS "contain at least one file (BBS-File).  The file list (BBS-File) residing"
  852.     MESS "there may be updated with from the main menu of this script."
  853.     MESS " "
  854.     MESS "BBS File subdir (carriage return accepts): "
  855. ;
  856. ;    Wait for entry, and interpret
  857. ;
  858.     S0 = "    "             ; Default value
  859.     GET S0 50        ; Wait for a char
  860.     IF NULL S0 GOTO FISDEND ; Nothing entered
  861.     GOSUB CheckSd        ; Test for create needed
  862.     IF FAILED GOTO FISDEND    ; Skip if create failed
  863.     GOSUB NewFile        ; Create needed file (if d.n.e)
  864. ;
  865. ;    Save the value
  866. ;
  867.     S23 = S0        ; Set new value
  868.     GOSUB Save        ; Save the new value
  869. ;
  870. ;    End of window
  871. ;
  872. FISDEND:
  873.     WCLOSE
  874.     RETURN
  875. ;
  876. ; ----- Subroutine: MailSd -> Set the mail subdirectory
  877. ;
  878. MailSd:
  879.     WOPEN 0,0 23,79 (defa) Main_Esc
  880.     ATSAY 0,2 (defa)   " BBS Mail Subdir "
  881.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  882.     LOCATE 2,2
  883.  
  884.     MESS "The BBS Mail subdirectory is: "
  885.     MESS S24
  886.     MESS " "
  887.     MESS "The Mail subdirectory must exist (it will be created if need be), and will "
  888.     MESS "contain at least one file (BBS-Mail).  The user ID file (BBS-Mail) residing"
  889.     MESS "there may be updated with from the main menu of this script."
  890.     MESS " "
  891.     MESS "BBS Mail subdir (carriage return accepts): "
  892. ;
  893. ;    Wait for entry, and interpret
  894. ;
  895.     S0 = "    "             ; Default value
  896.     GET S0 50        ; Wait for a char
  897.     IF NULL S0 GOTO MLSDEND ; Nothing entered
  898.     GOSUB CheckSd        ; Test for create needed
  899.     IF FAILED GOTO MLSDEND    ; Skip if create failed
  900.     GOSUB NewMail        ; Create needed file (if d.n.e)
  901. ;
  902. ;    Save the value
  903. ;
  904.     S24 = S0        ; Set new value
  905.     GOSUB Save        ; Save the new value
  906. ;
  907. ;    End of window
  908. ;
  909. MLSDEND:
  910.     WCLOSE
  911.     RETURN
  912. ;
  913. ; ----- Subroutine: BullSd -> Set the bulletin subdirectory
  914. ;
  915. BullSd:
  916.     WOPEN 0,0 23,79 (defa) Main_Esc
  917.     ATSAY 0,2 (defa)   " BBS Bulletin Subdir "
  918.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  919.     LOCATE 2,2
  920.  
  921.     MESS "The BBS bulletin subdirectory is: "
  922.     MESS S25
  923.     MESS " "
  924.     MESS "The Bulletin subdirectory must exist (it will be created if need be), and will "
  925.     MESS "contain at least one file (BBS-Bull).  The user ID file (BBS-Bull) residing"
  926.     MESS "there may be updated with from the main menu of this script."
  927.     MESS " "
  928.     MESS "BBS Bulletin subdir (carriage return accepts): "
  929. ;
  930. ;    Wait for entry, and interpret
  931. ;
  932.     S0 = "    "             ; Default value
  933.     GET S0 50        ; Wait for a char
  934.     IF NULL S0 GOTO BUSDEND ; Nothing entered
  935.     GOSUB CheckSd        ; Test for create needed
  936.     IF FAILED GOTO BUSDEND    ; Skip if create failed
  937.     GOSUB NewBull        ; Create needed file (if d.n.e)
  938. ;
  939. ;    Save the value
  940. ;
  941.     S25 = S0        ; Set new value
  942.     GOSUB Save        ; Save the new value
  943. ;
  944. ;    End of window
  945. ;
  946. BUSDEND:
  947.     WCLOSE
  948.     RETURN
  949.