home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / HILFEN / MODEM / COMAND28 / LEARN.SRC < prev    next >
Text File  |  1993-12-01  |  49KB  |  1,804 lines

  1.    SET TTHRU OFF        ; Make first to allow typeahead
  2.    S19 = "Learn   ver 1.0     " ; 20 chars long
  3. ; ----- Learn: Learn mode shell for COM-AND
  4. ;
  5. ;    R.McG; 8/89, Chicago
  6. ; ----------------------------------------------------------------
  7. ; Usages:
  8. ;      S19 -----> Legend line
  9. ;      S18 -----> Load-time drive:subdirectory (for exit)
  10. ;      S17 -----> Load-time download d:subdir (for exit)
  11. ;      S16 -----> Output file name
  12. ;      S12 -----> Text before last line displayed to screen
  13. ;      S11 -----> Last line displayed to screen
  14. ;      S10 -----> Current output buffer
  15. ;
  16. ;      N99 -----> Number of lines on screen
  17. ;      N96 -----> Current receive area cursor
  18. ;      N95 -----> Current receive area cursor
  19. ;      N94 -----> Current Kbd area cursor
  20. ;      N93 -----> Current Kbd area cursor
  21. ;      N92 -----> Saved cursor on entry
  22. ;      N91 -----> Saved cursor on entry
  23. ;      N90 -----> Current output buffer index
  24. ;
  25. ;      FLAG(0) -> Off: learning,    on: ready to terminate
  26. ;      FLAG(1) -> Off: no printer    on: Printer in use
  27. ;      FLAG(2) -> Off: log not used    on: Log was used
  28. ;      FLAG(8) -> Off: learning,    on: learning suspended
  29. ;      FLAG(9) -> Off: in line mode, on: in character mode
  30. ; -----------------------------------------------------------------------
  31. ;
  32. ;    Initialization
  33. ;
  34.    CURSOR N91,N92        ; Read current cursor
  35.    LEGEND S19            ; Set initial legend
  36.    SUBDIR S18            ; Read current subdir
  37.    DLDIR S17            ; Read current download subdir
  38.    SSIZE N99            ; Get current screen size
  39.    SAVE 0,0,N99-2,79        ; Save original screen
  40.    ON ESCAPE GOSUB ESCAPE    ; Escape action
  41.    SET FLAG(1) OFF        ; Set printer on/off flag
  42.    IF STRCMP "_PRIN" "ON"       ; .. as we only turn printer on
  43.       SET FLAG(1) ON        ; .. during receive portion
  44.       PRINTER OFF        ; Turn printer off unconditionally
  45.       ENDIF
  46. ;
  47. ;    Ask for an output file name
  48. ;
  49. Get_Output:
  50.    S1 = "Enter a file name to be output:"
  51.    GOSUB Ask_File        ; Ask for an output file
  52.    IF NOT SUCCESS EXIT        ; If ESC'd then stop
  53.    S16 = S0            ; Save fname
  54. ;
  55. ;    Test for file existing
  56. ;
  57.    IF ISFILE S16        ; If file exists
  58.       S0 = S16 *" already exists.  Overwrite it? Y/N (cr=no)"
  59.       GOSUB Ask_YN
  60.       IF NOT SUCCESS GOTO Get_Output
  61.       ENDIF
  62. ;
  63. ;    Open the output file, no append
  64. ;
  65.    FOPENO S16 TEXT        ; Open output file
  66.    IF NOT SUCCESS
  67.       S0 = "Error opening output file: "*S16
  68.       GOSUB Error        ; Report
  69.       GOTO Get_output
  70.       ENDIF
  71. ;
  72. ;    Perform other initialization
  73. ;
  74.    GOSUB Initial        ; Save initial settings
  75.    SET CHAT OFF         ; Turn off chat
  76.    GOTO START            ; And continue
  77. ;
  78. ; ----- Subroutine: Escape - Set a flag for mainline loop
  79. ;
  80. Escape:
  81.    SET FLAG(0) ON        ; Flag fact
  82.    RETURN            ; And continue
  83. ;
  84. ;------ Subroutine: Terminate the all LEARN script activity
  85. ;
  86. End_Learn:
  87.    DWINDOW CLEAR        ; Clear display window
  88.    IF FLAG(2) and STRCMP "_LOGG" "ON "
  89.       WRITE "LOG CLOSE!"        ; FInish logging if on and turned on within
  90.       LOG CLOSE
  91.       ENDIF
  92.    WRITE "^Z" 2                 ; Terminate w/EOF
  93.    FCLOSEO            ; Close output file
  94.    SET DLDIR S17        ; Reset DLDIR  to load time
  95.    CHDIR S18            ; Reset default subdir to load time
  96.    RESTORE            ; Restore screen
  97.    LOCATE N91,N92        ; Restore cursor
  98.    IF FLAG(1)            ; Set printer according to current state
  99.       PRINTER ON
  100.    ELSE
  101.       PRINTER OFF
  102.       ENDIF
  103.    RETURN            ; Rtn to caller
  104. ;
  105. ;------ Subroutine: Ask if Exit to be taken
  106. ;
  107. Exit:
  108.    S0 = "Do you wish to terminate LEARN?  Enter Y to terminate."
  109.    GOSUB Ask_YN
  110.    IF SUCCESS            ; IF answer is 'y'
  111.       GOSUB End_Learn        ; Terminate
  112.       EXIT            ; And stop script
  113.       ENDIF
  114.    SET FLAG(0) OFF        ; Clear ESC flag
  115.    RETURN            ; And continue
  116. ;
  117. ; ----- Main-line: Draw the screen, and begin loop
  118. ;
  119. Start:
  120.    N90 = 0            ; Initialize buffer index
  121.    S11 = ""                     ; Init last line received
  122.    S12 = ""                     ; Init next ot last line received
  123.    SET FLAG(0) OFF        ; Init ESC hit flag
  124.    SET FLAG(9) OFF        ; Init to line mode
  125.    SET FLAG(8) OFF        ; Init to not held
  126.    GOSUB Screen         ; Draw screen
  127.    LOCATE 1,1            ; Set cursor
  128.    DWINDOW N99-12,2 N99-12 77    ; Set kbd scrolling region
  129.    GOTO Main
  130. ;
  131. ;    Write a line (in S0, less CRLF) to the output file
  132. ;
  133. Output:
  134.    WRITE S0            ; Write to file
  135.    WRITE "!"                    ; Add a crlf
  136. ;
  137. ;    Display received text, and wait for a keypress
  138. ;
  139. Main:
  140.    LOCATE N93,N94        ; Set kbd cursor
  141.    IF FLAG(0) GOSUB Exit    ; If ESC pressed, ask if to exit
  142.    IF NOT HITKEY        ; If nothig on kbd
  143.       IF RECEIVE GOSUB Receive    ; Allow incoming text to be displayed
  144.       GOTO Main
  145.       ENDIF
  146. ;
  147. ;    We have a keypress pending
  148. ;
  149.    KEYGET S1            ; Read a single key
  150.    LENG S1 N0            ; Compute length of KEYGET
  151.    SWITCH N0
  152.       CASE 1            ; length = 1
  153.      GOTO ASCII
  154.       ENDCASE
  155.       CASE 2            ; length = 2
  156.      GOTO CONTROL
  157.       ENDCASE
  158.       CASE 4            ; length = 4
  159.      GOTO FUNCTION
  160.       ENDCASE
  161.    ENDSWITCH
  162.    GOTO Main            ; And continue
  163. ;
  164. ;    Update the keyboard display
  165. ;
  166. KbdDisp:
  167.    IF GT N90 0
  168.       S0 = S10(0:n90-1)     ; COpy current buffer
  169.       PRESERVE S0        ; Make displayable
  170.       ATSAY N99-12,2 (Default) S0 *"  "
  171.       ENDIF
  172.    N94=N90+2            ; Set new col #
  173.    GOTO Main
  174. ;
  175. ; ----- Subroutine: Handle receipt of text
  176. ;
  177. Receive:
  178.    DWINDOW 1, 0,(N99-14),79    ; Set rcv scrolling region
  179.    IF FLAG(1) PRINTER ON    ; Turn on printer while reading comm
  180.    LOCATE N95,N96        ; Set rcv cursor
  181.    S12 = S11            ; Save previous line read
  182.    RGET S11 80 1        ; Read new text, max wait 1 sec
  183.    CURSOR N95,N96        ; Read new rcv area cursor
  184.    IF FLAG(1) PRINTER OFF    ; Turn off printer now
  185.    DWINDOW N99-12,2 N99-12,77    ; Set kbd scrolling region
  186.    RETURN
  187. ;
  188. ;    ASCII char entered: length in N0 is 1
  189. ;
  190. ASCII:
  191.    IF FLAG(8)            ; If learn held
  192.       PRESERVE S1        ; ..
  193.       TRANSMIT S1        ; Send the char
  194.       GOTO Main         ; .. and no more
  195.       ENDIF
  196.    ;
  197.    ;    Catch buffer overflow (limit kbd buffer to 60 chars)
  198.    ;
  199.    IF GT (N90+2) 60
  200.       SOUND 100,100
  201.       GOTO Main
  202.       ENDIF
  203.    ;
  204.    ;    Buffer the char (preserving for TRANSMIT)
  205.    ;
  206.    S10(N90:N90) = S1        ; Buffer keystroke
  207.    INC N90
  208.    IF STRCMP S1 "!" or STRCMP S1 "^"
  209.       S10(N90:N90) = S1     ; DOuble special chars to PRESERVE for TRANSMIT
  210.       INC N90
  211.       ENDIF
  212.    ;
  213.    ;    If CHAR mode, send immediate
  214.    ;
  215.    IF FLAG(9) GOTO Transmit    ; If char mode transmit immediately
  216.    GOTO KbdDisp         ; Update kbd display
  217. ;
  218. ;    Handle control chars: length in N0 is 2
  219. ;
  220. Control:
  221.    S0 = "0x"*S1                 ; Make hex form of #
  222.    N0 = S0            ; If ctl char (e.g. 0d for c/r)
  223.    N0 = N0+64            ; Convert to ASCII @,A,B,...
  224.    S0 = "^"                     ; Store delimiter
  225.    ITOC N0 S0(1:1)        ; Store char being ctl'd
  226.    ;
  227.    ;    Simply xmit if LEARN HELD
  228.    ;
  229.    IF FLAG(8)            ; If learn held
  230.       TRANSMIT S0        ; Send the char
  231.       GOTO Main         ; .. and no more
  232.       ENDIF
  233.    ;
  234.    ;    Catch special control chars
  235.    ;
  236.    IF (NOT FLAG(9)) and STRCMP S1 "08" ; Catch backspace here
  237.       GOTO Backspace               ; .. in line mode
  238.       ENDIF
  239.    IF STRCMP S1 "0D"            ; Catch c/rs
  240.       GOTO RETURN        ; .. in either line or char mode
  241.       ENDIF
  242.    IF GT (N90+2) 60        ; Handle buffer overflow here
  243.       SOUND 100,100
  244.       GOTO Main
  245.       ENDIF
  246.    ;
  247.    ;    Buffer the remainder as "^" chars
  248.    ;
  249.    S10(N90:N90+1) = S0(0:1)    ; Store delimiter
  250.    N90 = N90+2
  251.    IF FLAG(9) GOTO Transmit    ; If char mode transmit directly
  252.    GOTO KbdDisp         ; Update kbd display
  253. ;
  254. ;    Backspace entered
  255. ;
  256. Backspace:
  257.    IF ZERO N90
  258.       GOTO KbdDisp
  259.       ENDIF
  260.    DEC N90
  261.    IF STRCMP S10(N90-1:N90-1) "^" or STRCMP S10(N90-1:N90) "!!"
  262.       DEC N90
  263.       ENDIF
  264.    GOTO KbdDisp         ; Update kbd display
  265. ;
  266. ;    Carriage return entered
  267. ;
  268. Return:
  269.    IF NOT ZERO N90
  270.       S10 = S10(0:N90-1)*"!"
  271.    ELSE
  272.       S10 = "!"
  273.       ENDIF
  274.    N90 = N90+1
  275. ;
  276. ;    Execute the current buffer
  277. ;
  278. Transmit:
  279.    GOSUB Waitfor        ; Emit a WAITFOR
  280.    ;
  281.    ;    Now, emit a TRANSMIT statement
  282.    ;
  283.    WRITE "TRANSMIT `""          ; Write TRANSMIT statement
  284.    IF STRCMP S10(N90-1:N90-1) "!!"
  285.       WRITE S10 N90-1        ; Write string to be xmitted less final c/r
  286.       WRITE "!!" 2              ; .. adding c/r after conversion
  287.    ELSE
  288.       WRITE S10 N90        ; Write string as-is
  289.       ENDIF
  290.    WRITE "`"!"                  ; .. finish the quoted string, and add a c/r
  291.    ;
  292.    ;    Perform the TRANSMIT and cleanup
  293.    ;
  294.    TRANSMIT S10(0:N90-1)
  295.    N90 = 0            ; Zero index to kbd buffer
  296.    CLEAR (default)        ; Clear kbd scrolling region
  297.    N94 = 2            ; Set cursor col
  298.    GOTO Main
  299. ;
  300. ; ----- Subroutine: Emit a WAITFOR
  301. ;
  302. Waitfor:
  303.    LJ S11            ; Left justify last text rcvd
  304.    S11 = S11&""                 ; Trim trailing spaces
  305.    LENGTH S11 N1        ; Length of last text rcvd
  306.    IF NOT ZERO N1        ; If a prompt (non null) was received
  307.       S0 = S11            ; Replicate
  308.       GOTO EmitWait        ; And emit a WAITFOR
  309.       ENDIF
  310.    ;
  311.    ;    Nothing received last... look at previous receipt
  312.    ;
  313.    LJ S12            ; Left justify
  314.    S12 = S12&""                 ; Trim trailing spaces
  315.    LENGTH S12 N1        ; length of text received prior to last
  316.    IF NOT ZERO N1        ; If a prompt (non null) was received
  317.       S0 = S12            ; Replicate
  318.       GOTO EmitWait        ; And emit a WAITFOR
  319.       ENDIF
  320.    ;
  321.    ;    Last 2 lines received were empty.
  322.    ;
  323.    WRITE ";!"                   ; Write a comment line
  324.    WRITE "; WAITFOR may be needed here!"
  325.    WRITE ";!"                   ; Write a comment line
  326.    RETURN
  327.    ;
  328.    ;    Emit a WAITFOR using the value in S0
  329.    ;
  330. EmitWait:
  331.    PRESERVE S0            ; Save carets/bangs
  332.    LENGTH S0 N1         ; Compute new length
  333.    WRITE "WAITFOR `""           ; Write WAITFOR
  334.    WRITE S0            ; Write string to be awaited
  335.    WRITE "`"!"                  ; .. finish the quoted string, and add a c/r
  336.    WRITE ";*IF NOT WAITFOR GOTO ...!"
  337.    S11 = ""                     ; Clear last receipt
  338.    S12 = ""                     ; ..
  339.    RETURN
  340. ;
  341. ;    Function key entered
  342. ;
  343. Function:
  344.    IF FLAG(8) and NOT STRCMP S1 "4000"
  345.       SOUND 100,100        ; Disallow if LEARN HELD
  346.       GOTO Main         ; .. and not the HOLD key
  347.       ENDIF
  348.    ;
  349.    ;    Interpret the char
  350.    ;
  351.    SWITCH S1
  352.       CASE "2E00"               ; Alt-C
  353.      GOTO Clear
  354.       ENDCASE
  355.       CASE "1200"               ; Alt-E
  356.      GOTO Echo
  357.       ENDCASE
  358.       CASE "2C00"               ; Alt-Z
  359.      GOTO Mask
  360.       ENDCASE
  361.       CASE "2600"               ; Alt-L
  362.      GOTO ScrSize
  363.       ENDCASE
  364.       CASE "2300"               ; Alt-H
  365.      GOTO Hangup
  366.       ENDCASE
  367.       CASE "2000"               ; Alt-D
  368.      GOTO Dial
  369.       ENDCASE
  370.       CASE "1900"               ; Alt-P
  371.      GOTO Parms
  372.       ENDCASE
  373.       CASE "3100"               ; Alt-N
  374.      GOTO Encrypt
  375.       ENDCASE
  376.       CASE "2200"               ; Alt-G
  377.      GOTO Blnkln
  378.       ENDCASE
  379.       CASE "1000"               ; Alt-Q
  380.      GOTO CRLF
  381.       ENDCASE
  382.  
  383.       CASE "7500"               ; Ctl-End
  384.      GOTO Break
  385.       ENDCASE
  386.       CASE "7200"               ; Ctl-PrtSc
  387.      GOTO Printer
  388.       ENDCASE
  389.       CASE "4900"               ; PgUp
  390.      GOTO Upload
  391.       ENDCASE
  392.       CASE "5100"               ; PgDn
  393.      GOTO Download
  394.       ENDCASE
  395.  
  396.       CASE "7800"               ; Alt-1
  397.      GOTO Alt_1
  398.       ENDCASE
  399.       CASE "7900"               ; Alt-2
  400.      GOTO Alt_2
  401.       ENDCASE
  402.       CASE "7A00"               ; Alt-3
  403.      GOTO Alt_3
  404.       ENDCASE
  405.       CASE "7B00"               ; Alt-4
  406.      GOTO Alt_4
  407.       ENDCASE
  408.       CASE "7C00"               ; Alt-5
  409.      GOTO Alt_5
  410.       ENDCASE
  411.       CASE "7D00"               ; Alt-6
  412.      GOTO Alt_6
  413.       ENDCASE
  414.       CASE "7E00"               ; Alt-7
  415.      GOTO Alt_7
  416.       ENDCASE
  417.       CASE "7F00"               ; Alt-8
  418.      GOTO Alt_8
  419.       ENDCASE
  420.       CASE "8000"               ; Alt-9
  421.      GOTO Alt_9
  422.       ENDCASE
  423.       CASE "8100"               ; Alt-0
  424.      GOTO Alt_0
  425.       ENDCASE
  426.  
  427.       CASE "3B00"               ; F1
  428.      GOTO Accessry
  429.       ENDCASE
  430.       CASE "3C00"               ; F2
  431.      GOTO Script
  432.       ENDCASE
  433.       CASE "3D00"               ; F3
  434.      GOTO Chdir
  435.       ENDCASE
  436.       CASE "3E00"               ; F4
  437.      GOTO DlDir
  438.       ENDCASE
  439.       CASE "3F00"               ; F5
  440.      GOTO LineChar
  441.       ENDCASE
  442.       CASE "4000"               ; F6
  443.      GOTO Hold
  444.       ENDCASE
  445.       CASE "4100"               ; F7
  446.      GOTO Log
  447.       ENDCASE
  448.       CASE "4300"               ; F9
  449.      GOTO LogHold
  450.       ENDCASE
  451.       CASE "4400"               ; F10
  452.      GOSUB Help        ; Note uncharacteristic GOSUB
  453.       ENDCASE
  454.       CASE "7100"               ; Alt-F10
  455.      GOTO Shell
  456.       ENDCASE
  457.       ;
  458.       ; Other keypresses are unrecognized
  459.       ;
  460.       DEFAULT
  461.      SOUND 100,100        ; Signal error
  462.       ENDCASE
  463.    ENDSWITCH
  464.    GOTO Main            ; And continue
  465. ;
  466. ;    Shell to DOS (for convenience only. SHELL is not written
  467. ;    .. to the learned script
  468. ;
  469. SHELL:
  470.    S16 = "_OFILE"               ; Save output fname
  471.    FCLOSEO            ; Close output file
  472.    DWINDOW Clear        ; Clear for implicit save
  473.    SHELL            ; Shell to DOS
  474.    DWINDOW N99-12,2 N99-12 77    ; ReSet kbd scrolling region
  475.    LEGEND S19            ; ReSet legend
  476.    FOPENO S16 TEXT APPEND    ; Allow edits during shell
  477.    GOTO Main
  478. ;
  479. ;    Clear the screen
  480. ;
  481. Clear:
  482.    DWINDOW 1, 0,(N99-14),79    ; Set rcv scrolling region
  483.    CLEAR (default)        ; Perform the clear function
  484.    CURSOR N95,N96        ; Set new cursor
  485.    DWINDOW N99-12,2 N99-12,77    ; Set kbd scrolling region
  486.    LOCATE N93,N94        ; Set kbd cursor
  487.    S0 = "CLEAR"                 ; Set-up the line to add to output
  488.    GOTO Output            ; Set-up the line to add to output
  489. ;
  490. ;    Toggle echo
  491. ;
  492. Echo:
  493.    S0 = "SET DUPLEX HALF"       ; Default as if full
  494.    IF STRCMP "_DUPL" "HALF"     ; Test current setting
  495.       S0 = "SET DUPLEX FULL"    ; Set-up cmd and output
  496.       ENDIF
  497.    PERFORM S0            ; Execute instruction in S0
  498.    GOSUB StatusLine
  499.    GOTO Output            ; Set-up the line to add to output
  500. ;
  501. ;    Toggle mask
  502. ;
  503. Mask:
  504.    S0 = "SET MASK ON"           ; Default as if off
  505.    IF STRCMP "_MASK" "ON "      ; Test current setting
  506.       S0 = "SET MASK OFF"       ; Set-up cmd and output
  507.       ENDIF
  508.    PERFORM S0            ; Execute instruction in S0
  509.    GOSUB StatusLine
  510.    GOTO Output            ; Set-up the line to add to output
  511. ;
  512. ;    Toggle screen size
  513. ;
  514. ScrSize:
  515.    S0 = "SET 43"
  516.    IF GT "_SSIZ" 25
  517.       S0 = "SET 25"
  518.       ENDIF
  519.    PERFORM S0            ; Execute instruction in S0
  520.    SSIZE N99            ; Get current screen size
  521.    GOSUB Screen         ; Redraw the screen
  522.    GOTO Output            ; Set-up the line to add to output
  523. ;
  524. ;    Send a macro
  525. ;
  526. Alt_0:
  527.    S0 = "MACRO 0"
  528.    GOTO Send_Macro        ; Set-up the line to add to output
  529. ;
  530. ;    Send a macro
  531. ;
  532. Alt_1:
  533.    S0 = "MACRO 1"
  534.    GOTO Send_Macro        ; Set-up the line to add to output
  535. ;
  536. ;    Send a macro
  537. ;
  538. Alt_2:
  539.    S0 = "MACRO 2"
  540.    GOTO Send_Macro        ; Set-up the line to add to output
  541. ;
  542. ;    Send a macro
  543. ;
  544. Alt_3:
  545.    S0 = "MACRO 3"
  546.    GOTO Send_Macro        ; Set-up the line to add to output
  547. ;
  548. ;    Send a macro
  549. ;
  550. Alt_4:
  551.    S0 = "MACRO 4"
  552.    GOTO Send_Macro        ; Set-up the line to add to output
  553. ;
  554. ;    Send a macro
  555. ;
  556. Alt_5:
  557.    S0 = "MACRO 5"
  558.    GOTO Send_Macro        ; Set-up the line to add to output
  559. ;
  560. ;    Send a macro
  561. ;
  562. Alt_6:
  563.    S0 = "MACRO 6"
  564.    GOTO Send_Macro        ; Set-up the line to add to output
  565. ;
  566. ;    Send a macro
  567. ;
  568. Alt_7:
  569.    S0 = "MACRO 7"
  570.    GOTO Send_Macro        ; Set-up the line to add to output
  571. ;
  572. ;    Send a macro
  573. ;
  574. Alt_8:
  575.    S0 = "MACRO 8"
  576.    GOTO Send_Macro        ; Set-up the line to add to output
  577. ;
  578. ;    Send a macro
  579. ;
  580. Alt_9:
  581.    S0 = "MACRO 9"
  582. ;
  583. ;    Finally, for all the above, send it
  584. ;
  585. Send_Macro:
  586.    PERFORM S0            ; Execute instruction in S0
  587.    GOTO Output            ; Set-up the line to add to output
  588. ;
  589. ;    Hangup
  590. ;
  591. Hangup:
  592.    GOSUB Waitfor        ; Emit waitfor
  593.    S0 = "HANGUP"
  594.    PERFORM S0            ; Execute instruction in S0
  595.    GOTO Output            ; Set-up the line to add to output
  596. ;
  597. ;    Send a break
  598. ;
  599. Break:
  600.    GOSUB Waitfor        ; Emit waitfor
  601.    S0 = "BREAK"
  602.    PERFORM S0            ; Execute instruction in S0
  603.    GOTO Output            ; Set-up the line to add to output
  604. ;
  605. ;    Toggle printer
  606. ;
  607. Printer:
  608.    IF FLAG(1)            ; Test flagged state
  609.       S0 = "PRINTER OFF"        ; .. If set printer is ON during rcv
  610.       SET FLAG(1) OFF
  611.    ELSE             ; Else its off now
  612.       S0 = "PRINTER ON"
  613.       SET FLAG(1) ON
  614.       ENDIF
  615.    WRITE S0*"!"                 ; LOG instruction in S0
  616.    GOSUB StatusLine
  617.    GOTO Main            ; Set-up the line to add to output
  618. ;
  619. ;    Toggle line/char mode
  620. ;
  621. LineChar:
  622.    IF FLAG(9)
  623.       SET FLAG(9) OFF
  624.    ELSE
  625.       SET FLAG(9) ON
  626.       ENDIF
  627.    GOSUB StatusLine
  628.    GOTO Main
  629. ;
  630. ;    Toggle learn hold
  631. ;
  632. Hold:
  633.    IF FLAG(8)
  634.       SET FLAG(8) OFF
  635.    ELSE
  636.       SET FLAG(8) ON
  637.       ENDIF
  638.    GOSUB StatusLine        ; Update status line
  639.    GOTO Main
  640. ;
  641. ; ----- Subroutine:  Upload current file
  642. ;
  643. UpLoad:
  644.    GOSUB Ask_Method
  645.    S1 = "/NONAME/"              ; Make file name null
  646.    SWITCH S0
  647.       CASE "_NULL"              ; No entry
  648.     SOUND 100,100
  649.     GOTO Main        ; No action
  650.       ENDCASE            ; .. no action
  651.       CASE "1"                  ; WXMODEM
  652.      GOSUB Ask_Name     ; Ask for fname in S1
  653.      S0 = "SENDFILE WXMODEM S1"
  654.       ENDCASE
  655.       CASE "2"                  ; XMODEM
  656.      GOSUB Ask_Name     ; Ask for fname in S1
  657.      S0 = "SENDFILE XMODEM S1"
  658.       ENDCASE
  659.       CASE "3"                  ; ASCII
  660.      GOSUB Ask_Name     ; Ask for fname in S1
  661.      S0 = "SENDFILE ASCII S1"
  662.       ENDCASE
  663.       CASE "4"                  ; YMODEM/XMODEM1K
  664.      GOSUB Ask_Name     ; Ask for fname in S1
  665.      S0 = "SENDFILE YMODEM S1"
  666.       ENDCASE
  667.       CASE "5"                  ; CISB
  668.      S0 = "SENDFILE CISB"
  669.       ENDCASE
  670.       CASE "6"                  ; QuickB
  671.      S0 = "SENDFILE QuickB"
  672.       ENDCASE
  673.       CASE "7"                  ; KERMIT
  674.      GOSUB Ask_Name     ; Ask for fname in S1
  675.      S0 = "SENDFILE KERMIT S1"
  676.       ENDCASE
  677.       CASE "8"                  ; Batch YMODEM
  678.      GOSUB Ask_Name     ; Ask for fname in S1
  679.      S0 = "SENDFILE BYMODEM S1"
  680.       ENDCASE
  681.       CASE "9"                  ; Batch YMODEM-G
  682.      GOSUB Ask_Name     ; Ask for fname in S1
  683.      S0 = "SENDFILE BYMOG S1"
  684.       ENDCASE
  685.  
  686.       DEFAULT
  687.     SOUND 100,100
  688.     GOTO Main        ; No action
  689.       ENDCASE
  690.    ENDSWITCH
  691. ;
  692. ;    If we have a valid file name, perform it
  693. ;
  694. Transfer:
  695.    IF NULL S1            ; Catch failed Ask_Name
  696.       GOTO Main
  697.       ENDIF
  698.    PERFORM S0
  699.    IF NOT STRCMP S1 "/NONAME/"
  700.       WRITE "; File transfer!"
  701.       WRITE "MESS `"Enter the file name: `"!"
  702.       WRITE "GET S1 60!"
  703.       ENDIF
  704.    GOTO Output             ; LOG the file name too
  705. ;
  706. ; ----- Subroutine:  Upload current file
  707. ;
  708. DownLoad:
  709.    GOSUB Ask_Method
  710.    S1 = "/NONAME/"              ; Make file name null
  711.    SWITCH S0
  712.       CASE "_NULL"              ; No entry
  713.     SOUND 100,100
  714.     GOTO Main        ; No action
  715.       ENDCASE            ; .. no action
  716.       CASE "1"                  ; WXMODEM
  717.      GOSUB Ask_Name     ; Ask for fname in S1
  718.      S0 = "GETFILE WXMODEM S1"
  719.       ENDCASE
  720.       CASE "2"                  ; XMODEM
  721.      GOSUB Ask_Name     ; Ask for fname in S1
  722.      S0 = "GETFILE XMODEM S1"
  723.       ENDCASE
  724.       CASE "3"                  ; ASCII
  725.      GOSUB Ask_Name     ; Ask for fname in S1
  726.      S0 = "GETFILE ASCII S1"
  727.       ENDCASE
  728.       CASE "4"                  ; YMODEM/XMODEM1K
  729.      GOSUB Ask_Name     ; Ask for fname in S1
  730.      S0 = "GETFILE YMODEM S1"
  731.       ENDCASE
  732.       CASE "5"                  ; CISB
  733.      S0 = "GETFILE CISB"
  734.       ENDCASE
  735.       CASE "6"                  ; QuickB
  736.      S0 = "GETFILE QuickB"
  737.       ENDCASE
  738.       CASE "7"                  ; KERMIT
  739.      S0 = "GETFILE KERMIT"
  740.       ENDCASE
  741.       CASE "8"                  ; Batch YMODEM
  742.      S0 = "GETFILE BYMODEM"
  743.       ENDCASE
  744.       CASE "9"                  ; Batch YMODEM-G
  745.      S0 = "GETFILE BYMOG"
  746.       ENDCASE
  747.       DEFAULT
  748.     SOUND 100,100
  749.     GOTO Main        ; No action
  750.       ENDCASE
  751.    ENDSWITCH
  752.    GOTO Transfer
  753. ;
  754. ; ----- Subroutine: Ask for the upload method
  755. ;    S0 returns the selected method # (1-9) or null
  756. ;    S12 returns the from file name
  757. ;
  758. Ask_Method:
  759.    WOPEN  2 20 14 60 (contrast) ASK_ESC
  760.    ATSAY  2 22 (contrast) " Learn UpLoad/Download "
  761.    ATSAY  3 22 (contrast) " 1) Windowed XMODEM"
  762.    ATSAY  4 22 (contrast) " 2) CRC/Checksum XMODEM"
  763.    ATSAY  5 22 (contrast) " 3) ASCII transfer "
  764.    ATSAY  6 22 (contrast) " 4) YMODEM/XMODEM-1K"
  765.    ATSAY  7 22 (contrast) " 5) CIS-B          "
  766.    ATSAY  8 22 (contrast) " 6) CIS Quick-B    "
  767.    ATSAY  9 22 (contrast) " 7) Kermit         "
  768.    ATSAY 10 22 (contrast) " 8) Batch YMODEM   "
  769.    ATSAY 11 22 (contrast) " 9) Batch YMODEM-G "
  770.    ATSAY 12 20 (contrast)  "├───────────────────────────────────────┤"
  771.    ATSAY 13 22 (contrast) "Enter method #:"
  772.    ATSAY 14 30 (contrast) " Press ESC to cancel "
  773.  
  774.    ATGET 13 48 (contrast) 1 S0 ; Read new fname
  775.    WCLOSE
  776.    RETURN            ; And done
  777. ;
  778. ; ----- Subroutine: Ask for a up/down file name
  779. ;    SUCCESS returns fact script file successfully opened
  780. ;    S1 returns the fname
  781. ;
  782. Ask_Name:
  783.    WOPEN 10 10 13 70 (contrast) NAMEESC
  784.    ATSAY 10 12 (contrast) " Learn Up/Down Filename "
  785.    ATSAY 11 12 (contrast) "Enter a file name to be transferred:"
  786.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  787.  
  788.    ATGET 12 12 (contrast) 54 S1; Read new fname
  789.    WCLOSE
  790.    ;
  791.    ;       Attempt to execute the entry
  792.    ;
  793.    LJ S1            ; Left justify
  794.    S1 = S1&""                   ; Trim spaces
  795.    RETURN            ; And done
  796. NAMEESC:
  797.    S1 = ""
  798.    RETURN
  799. ;
  800. ;    Dial a number
  801. ;
  802. Dial:
  803.    GOSUB Ask_Dial        ; Get dial dir #
  804.    IF NOT SUCCESS or NULL S2    ; IF ESC'd out
  805.       GOTO Main
  806.       ENDIF
  807.    DIAL S2            ; Try to dial #
  808.    IF FAILED
  809.       GOTO Main
  810.       ENDIF
  811.    ;
  812.    ;    Write a DIAL paragraph to the output file
  813.    ;
  814.    WRITE "; Dialing!"
  815.    WRITE "IF NOT LINKED!"
  816.    WRITE "   DIAL `""
  817.    WRITE S2
  818.    WRITE "`"!"
  819.    WRITE "   IF FAILED EXIT!"
  820.    WRITE "   ENDIF!"
  821.    GOTO Main             ; LOG the file name too
  822. ;
  823. ; ----- Subroutine: Ask for the number to dial
  824. ;    S2 returns the selected entry # or null
  825. ;
  826. Ask_Dial:
  827.    N0 = 0            ; Page #
  828.    WOPEN  2 20 15 60 (contrast) ASK_ESC
  829.    ATSAY  2 22 (contrast) " Learn Dial  "
  830.    ATSAY 13 20 (contrast)  "├───────────────────────────────────────┤"
  831.    ATSAY 14 22 (contrast) "Enter entry #:"
  832.    ATSAY 15 30 (contrast) " Press ESC to cancel "
  833.    ;
  834.    ;    Display the current page
  835.    ;
  836. Dial_Loop:
  837.    SCROLL 0,  3,22 12,58 (contrast) ; Clear display area
  838.    FOR N1 = 1,10
  839.        N4 = N0+N1
  840.        DIRECTORY S0 N4
  841.        ATSAY (2+N1) 22 (contrast) N4*")"
  842.        ATSAY (2+N1) 27 (contrast) S0
  843.        ENDFOR
  844.    LOCATE 14 37
  845.    N2 = 37            ; Currnt cursor
  846.    S2 = ""                      ; Clear save buffer
  847.    ;
  848.    ;    Wait for a keypress
  849.    ;
  850. Dial_Key:
  851.    KEYGET S0            ; Read keypress
  852.    LENGTH S0 N1
  853.    SWITCH N1            ; Switch on length
  854.       CASE 1            ; Len = 1: ASCII char
  855.      IF NOT FIND "+-@#0123456789" S0
  856.         SOUND 100,100
  857.         GOTO Dial_Key
  858.         ENDIF
  859.      S2 = S2*S0        ; Save the keypress
  860.      ATSAY 14 N2 (contrast) S0
  861.      INC N2         ; Increment cursor
  862.      LOCATE 14 N2
  863.      GOTO Dial_Key
  864.       ENDCASE
  865.       CASE 2            ; Len = 2: ctl char
  866.      SWITCH S0        ; Handle individual ctl chars
  867.         CASE "0D"           ; Carriage rtn
  868.            SET SUCCESS ON
  869.            GOTO DIAL_End
  870.         ENDCASE
  871.         CASE "08"           ; Carriage rtn
  872.            LENGTH S2 N0
  873.            IF GT N0 1
  874.           S2 = S2(0:N0-2)
  875.           DEC N2    ; Increment cursor
  876.           LOCATE 14 N2
  877.           ATSAY 14 N2 (contrast) " "
  878.            ELSE
  879.           S2 = ""       ; Clear field so far
  880.           N2 = 37
  881.           ATSAY 14 N2 (contrast) " "
  882.           ENDIF
  883.            GOTO Dial_Key
  884.         ENDCASE
  885.         DEFAULT        ; Any other ctl char
  886.            SOUND 100,100
  887.            GOTO Dial_Key
  888.         ENDCASE
  889.      ENDSWITCH
  890.       ENDCASE            ; End len = 2
  891.       CASE 4
  892.      SWITCH S0        ; Len = 4: Ftn key
  893.         CASE "4900"         ; PgUp
  894.           N0 = N0-10
  895.           IF LT N0 0
  896.          N0 = 90
  897.          ENDIF
  898.           GOTO Dial_Loop
  899.         ENDCASE
  900.         CASE "5100"         ; PgDn
  901.           N0 = N0+10
  902.           IF GE N0 100
  903.          N0 = 0
  904.          ENDIF
  905.           GOTO Dial_Loop
  906.         ENDCASE
  907.         CASE "4700"         ; Home
  908.           N0 = 0
  909.           GOTO Dial_Loop
  910.         ENDCASE
  911.         CASE "4F00"         ; End
  912.           N0 = 90
  913.           GOTO Dial_Loop
  914.         ENDCASE
  915.         DEFAULT        ; Any other ftn keyr
  916.            SOUND 100,100
  917.            GOTO Dial_Key
  918.         ENDCASE
  919.      ENDSWITCH
  920.       ENDCASE
  921.       DEFAULT            ; Len <> 1,2,4... e.g. esc
  922.      SET SUCCESS OFF
  923.       ENDCASE
  924.    ENDSWITCH
  925. Dial_End:
  926.    WCLOSE
  927.    RETURN            ; And done
  928. ;
  929. ;    Load an accessory
  930. ;
  931. Accessry:
  932.    GOSUB Ask_AccNum        ; Get acc dir #
  933.    IF NOT SUCCESS or NULL S2    ; IF ESC'd out
  934.       GOTO Main
  935.       ENDIF
  936.    S0 = "WARNING: An accessory ends LEARN.  Enter Y to proceed."
  937.    GOSUB Ask_YN
  938.    IF NOT SUCCESS        ; IF ESC'd out
  939.       GOTO Main
  940.       ENDIF
  941.    ;
  942.    ;    Write an ACC paragraph to the output file
  943.    ;
  944.    WRITE "; Accessory!"
  945.    WRITE "ACCESSORY `""
  946.    LENGTH S2 N2
  947.    WRITE S2 N2
  948.    WRITE "`"!"
  949.    GOSUB End_Learn        ; Terminate output
  950.    ;
  951.    ;    And execute the accessory
  952.    ;
  953.    ACCESSORY S2         ; Load accessory
  954. Dummy1:
  955.    GOTO Main            ; Branch if EXECUTE fails
  956. ;
  957. ; ----- Subroutine: Ask for the entry number to execute
  958. ;    S2 returns the selected entry # or null
  959. ;
  960. Ask_AccNum:
  961.    N0 = 0            ; Page #
  962.    WOPEN  2 10 15 70 (contrast) ASK_ESC
  963.    ATSAY  2 12 (contrast) " Learn Accessory "
  964.    ATSAY 13 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  965.    ATSAY 14 12 (contrast) "Enter entry #:"
  966.    ATSAY 15 20 (contrast) " Press ESC to cancel "
  967.    ;
  968.    ;    Display the current page
  969.    ;
  970. Acc_Loop:
  971.    SCROLL 0,  3,12 12,68 (contrast) ; Clear display area
  972.    FOR N1 = 1,10
  973.        N4 = N0+N1
  974.        ANAME S0 N4
  975.        ATSAY (2+N1) 12 (contrast) N4*")"
  976.        ATSAY (2+N1) 17 (contrast) S0
  977.        ENDFOR
  978.    LOCATE 14 27
  979.    N2 = 27            ; Currnt cursor
  980.    S2 = ""                      ; Clear save buffer
  981.    ;
  982.    ;    Wait for a keypress
  983.    ;
  984. Acc_Key:
  985.    KEYGET S0            ; Read keypress
  986.    LENGTH S0 N1
  987.    SWITCH N1            ; Switch on length
  988.       CASE 1            ; Len = 1: ASCII char
  989.      IF NOT FIND "0123456789" S0
  990.         SOUND 100,100
  991.         GOTO Acc_Key
  992.         ENDIF
  993.      S2 = S2*S0        ; Save the keypress
  994.      ATSAY 14 N2 (contrast) S0
  995.      INC N2         ; Increment cursor
  996.      LOCATE 14 N2
  997.      GOTO Acc_Key
  998.       ENDCASE
  999.       CASE 2            ; Len = 2: ctl char
  1000.      SWITCH S0        ; Handle individual ctl chars
  1001.         CASE "0D"           ; Carriage rtn
  1002.            SET SUCCESS ON
  1003.            GOTO Acc_End
  1004.         ENDCASE
  1005.         CASE "08"           ; Carriage rtn
  1006.            LENGTH S2 N0
  1007.            IF GT N0 1
  1008.           S2 = S2(0:N0-2)
  1009.           DEC N2    ; Increment cursor
  1010.           LOCATE 14 N2
  1011.           ATSAY 14 N2 (contrast) " "
  1012.            ELSE
  1013.           S2 = ""       ; Clear field so far
  1014.           N2 = 27
  1015.           ATSAY 14 N2 (contrast) " "
  1016.           ENDIF
  1017.            GOTO Acc_Key
  1018.         ENDCASE
  1019.         DEFAULT        ; Any other ctl char
  1020.            SOUND 100,100
  1021.            GOTO Acc_Key
  1022.         ENDCASE
  1023.      ENDSWITCH
  1024.       ENDCASE            ; End len = 2
  1025.       CASE 4
  1026.      SWITCH S0        ; Len = 4: Ftn key
  1027.         CASE "4900"         ; PgUp
  1028.           N0 = N0-10
  1029.           IF LT N0 0
  1030.          N0 = 40
  1031.          ENDIF
  1032.           GOTO Acc_Loop
  1033.         ENDCASE
  1034.         CASE "5100"         ; PgDn
  1035.           N0 = N0+10
  1036.           IF GE N0 50
  1037.          N0 = 0
  1038.          ENDIF
  1039.           GOTO Acc_Loop
  1040.         ENDCASE
  1041.         CASE "4700"         ; Home
  1042.           N0 = 0
  1043.           GOTO Acc_Loop
  1044.         ENDCASE
  1045.         CASE "4F00"         ; End
  1046.           N0 = 40
  1047.           GOTO Acc_Loop
  1048.         ENDCASE
  1049.         DEFAULT        ; Any other ftn keyr
  1050.            SOUND 100,100
  1051.            GOTO Acc_Key
  1052.         ENDCASE
  1053.      ENDSWITCH
  1054.       ENDCASE
  1055.       DEFAULT            ; Len <> 1,2,4... e.g. esc
  1056.      SET SUCCESS OFF
  1057.       ENDCASE
  1058.    ENDSWITCH
  1059. Acc_End:
  1060.    WCLOSE
  1061.    RETURN            ; And done
  1062. ;
  1063. ;    Load a script
  1064. ;
  1065. Script:
  1066.    S1 = "Enter the script file name:"
  1067.    GOSUB Ask_File        ; Get script file name
  1068.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1069.       GOTO Main
  1070.       ENDIF
  1071.    S2 = S0            ; Save fname
  1072.    IF NOT ISSCFILE S2        ; Test for presence
  1073.       S0 = "Script file not found: "*S2
  1074.       GOSUB Error
  1075.       GOTO Script
  1076.       ENDIF
  1077.    ;
  1078.    ;    Warn termination
  1079.    ;
  1080.    S0 = "WARNING: A script call ends LEARN.  Enter Y to proceed."
  1081.    GOSUB Ask_YN
  1082.    IF NOT SUCCESS        ; IF ESC'd out
  1083.       GOTO Main
  1084.       ENDIF
  1085.    ;
  1086.    ;    Write a script paragraph to the output file
  1087.    ;
  1088.    WRITE "; Script!"
  1089.    WRITE "EXECUTE `""
  1090.    WRITE S2
  1091.    WRITE "`"!"
  1092.    GOSUB End_Learn        ; Terminate output
  1093.    ;
  1094.    ;    And execute the script
  1095.    ;
  1096.    EXECUTE S2            ; Load accessory
  1097. Dummy2:
  1098.    GOTO Main            ; Branch if EXECUTE fails
  1099. ;
  1100. ;    Change drive:subdir
  1101. ;
  1102. Chdir:
  1103.    S1 = "Enter the new drive:subdirectory:"
  1104.    GOSUB Ask_File        ; Get script file name
  1105.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1106.       GOTO Main
  1107.       ENDIF
  1108.    S0 = "CHDIR `""*S0&"`""
  1109.    PERFORM S0            ; Execute instruction in S0
  1110.    GOTO Output            ; Set-up the line to add to output
  1111. ;
  1112. ;    Change default dload drive:subdir
  1113. ;
  1114. DlDir:
  1115.    S1 = "Enter the new download drive:subdirectory:"
  1116.    GOSUB Ask_File        ; Get script file name
  1117.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1118.       GOTO Main
  1119.       ENDIF
  1120.    S0 = "SET DLDIR `""*S0&"`""
  1121.    PERFORM S0            ; Execute instruction in S0
  1122.    GOTO Output            ; Set-up the line to add to output
  1123. ;
  1124. ;    Toggle the log function
  1125. ;
  1126. Log:
  1127.    IF STRCMP "_LOGG" "OFF"
  1128.       S1 = "Enter the transcript file name:"
  1129.       GOSUB Ask_File        ; Get script file name
  1130.       IF NOT SUCCESS or NULL S0 ; IF ESC'd out
  1131.      GOTO Main
  1132.      ENDIF
  1133.       S0 = "LOG OPEN `""*S0&"`""
  1134.       SET FLAG(2) ON        ; Flag fact for exit
  1135.    ELSE
  1136.       IF NOT FLAG(2)        ; If was on when entered
  1137.      LOG CLOSE        ; Close the log
  1138.      GOTO Main        ; And don't add to output
  1139.      ENDIF
  1140.       S0 = "LOG CLOSE"
  1141.       ENDIF
  1142.    PERFORM S0            ; Execute instruction in S0
  1143.    GOSUB StatusLine        ; Update statusline
  1144.    GOTO Output            ; Set-up the line to add to output
  1145. ;
  1146. ;    Toggle the log hold function
  1147. ;
  1148. LogHold:
  1149.    IF STRCMP "_LOGG" "OFF"      ; If not logging
  1150.       GOTO Main
  1151.       ENDIF
  1152.    IF STRCMP "_LOGH" "OFF"
  1153.       S0 = "LOG SUSPEND"
  1154.    ELSE
  1155.       S0 = "LOG RESUME"
  1156.       ENDIF
  1157.    PERFORM S0            ; Execute instruction in S0
  1158.    GOSUB StatusLine        ; Update statusline
  1159.    GOTO Output            ; Set-up the line to add to output
  1160. ;
  1161. ;    Set comm parms
  1162. ;
  1163. Parms:
  1164.    S0 = ""                      ; Default target vars
  1165.    S1 = ""                      ; ..
  1166.    S2 = ""                      ; ..
  1167.    S3 = ""                      ; ..
  1168.    GOSUB Ask_Parms        ; Ask for a number
  1169.    LJ S0            ; Left justify response
  1170.    SWITCH S0            ; Switch on response in Get_parms
  1171.       CASE "_NULL"              ; No entry
  1172.      SOUND 100,100
  1173.      GOTO Main        ; No action
  1174.       ENDCASE            ; .. no action
  1175.       CASE "1"                  ;  300,e,7,1
  1176.      S0 = "SET BAUD 300"
  1177.      GOTO Even_7_1
  1178.       ENDCASE
  1179.       CASE "2"                  ; 1200,e,7,1
  1180.      S0 = "SET BAUD 1200"
  1181.      GOTO Even_7_1
  1182.       ENDCASE
  1183.       CASE "3"                  ; 2400,e,7,1
  1184.      S0 = "SET BAUD 2400"
  1185.      GOTO Even_7_1
  1186.       ENDCASE
  1187.       CASE "4"                  ; 4800,e,7,1
  1188.      S0 = "SET BAUD 4800"
  1189.      GOTO Even_7_1
  1190.       ENDCASE
  1191.       CASE "5"                  ; 9600,e,7,1
  1192.      S0 = "SET BAUD 9600"
  1193.      GOTO Even_7_1
  1194.       ENDCASE
  1195.       CASE "6"                  ; 19.2,e,7,1
  1196.      S0 = "SET BAUD 19K"
  1197.      GOTO Even_7_1
  1198.       ENDCASE
  1199.       CASE "7"                  ; 38.4,e,7,1
  1200.      S0 = "SET BAUD 38K"
  1201.      GOTO Even_7_1
  1202.       ENDCASE
  1203.       CASE "8"                  ; 57.6,e,7,1
  1204.      S0 = "SET BAUD 57K"
  1205.      GOTO Even_7_1
  1206.       ENDCASE
  1207.       CASE "9"                  ; 115K,e,7,1
  1208.      S0 = "SET BAUD 115K"
  1209.      GOTO Even_7_1
  1210.       ENDCASE
  1211.       CASE "10"                 ;  300,n,7,1
  1212.      S0 = "SET BAUD 300"
  1213.      GOTO None_8_1
  1214.       ENDCASE
  1215.       CASE "11"                 ; 1200,n,7,1
  1216.      S0 = "SET BAUD 1200"
  1217.      GOTO None_8_1
  1218.       ENDCASE
  1219.       CASE "12"                 ; 2400,n,7,1
  1220.      S0 = "SET BAUD 2400"
  1221.      GOTO None_8_1
  1222.       ENDCASE
  1223.       CASE "13"                 ; 4800,n,7,1
  1224.      S0 = "SET BAUD 4800"
  1225.      GOTO None_8_1
  1226.       ENDCASE
  1227.       CASE "14"                 ; 9600,n,7,1
  1228.      S0 = "SET BAUD 9600"
  1229.      GOTO None_8_1
  1230.       ENDCASE
  1231.       CASE "15"                 ; 19.2,n,7,1
  1232.      S0 = "SET BAUD 19K"
  1233.      GOTO None_8_1
  1234.       ENDCASE
  1235.       CASE "16"                 ; 38.4,n,7,1
  1236.      S0 = "SET BAUD 38k"
  1237.      GOTO None_8_1
  1238.       ENDCASE
  1239.       CASE "17"                 ; 57.6,n,7,1
  1240.      S0 = "SET BAUD 57k"
  1241.      GOTO None_8_1
  1242.       ENDCASE
  1243.       CASE "18"                 ; 115K,n,7,1
  1244.      S0 = "SET BAUD 115K"
  1245.      GOTO None_8_1
  1246.       ENDCASE
  1247.       CASE "19"                 ; Even parity
  1248.      S0 = "SET PARITY EVEN"
  1249.       ENDCASE
  1250.       CASE "20"                 ; Odd parity
  1251.      S0 = "SET PARITY ODD"
  1252.       ENDCASE
  1253.       CASE "21"                 ; No parity
  1254.      S0 = "SET PARITY ODD"
  1255.       ENDCASE
  1256.       CASE "22"                 ; 7 data
  1257.      S0 = "SET DATA 7"
  1258.       ENDCASE
  1259.       CASE "23"                 ; 8 data
  1260.      S0 = "SET DATA 8"
  1261.       ENDCASE
  1262.       CASE "24"                 ; 1 stop bits
  1263.      S0 = "SET STOP 1"
  1264.       ENDCASE
  1265.       CASE "25"                 ; 2 stop bits
  1266.      S0 = "SET STOP 2"
  1267.       ENDCASE
  1268.       CASE "26"                 ; COM1
  1269.      S0 = "SET PORT COM1"
  1270.       ENDCASE
  1271.       CASE "27"                 ; COM2
  1272.      S0 = "SET PORT COM2"
  1273.       ENDCASE
  1274.       CASE "28"                 ; COM3
  1275.      S0 = "SET PORT COM3"
  1276.       ENDCASE
  1277.       CASE "29"                 ; COM4
  1278.      S0 = "SET PORT COM4"
  1279.       ENDCASE
  1280.       DEFAULT
  1281.     SOUND 100,100
  1282.     GOTO Parms        ; Repeat request
  1283.       ENDCASE
  1284.    ENDSWITCH
  1285.    GOTO End_Parms
  1286.    ;
  1287.    ;    Set EVEN,7,1 in addition to S0 already set
  1288.    ;
  1289. Even_7_1:
  1290.    S1 = "SET PARITY EVEN"        ; Set-up alternate vars
  1291.    S2 = "SET DATA 7"
  1292.    S3 = "SET STOP 1"
  1293.    GOTO End_Parms
  1294.    ;
  1295.    ;    Set NONE,8,1 too
  1296.    ;
  1297. None_8_1:
  1298.    S1 = "SET PARITY NONE"        ; Set-up alternate vars
  1299.    S2 = "SET DATA 8"
  1300.    S3 = "SET STOP 1"
  1301.    ;
  1302.    ;    Execute the command and write to script
  1303.    ;
  1304. End_Parms:
  1305.    IF NOT NULL S0
  1306.       PERFORM S0        ; Execute
  1307.       WRITE S0*"!"              ; Write to log file
  1308.       ENDIF
  1309.    IF NOT NULL S1
  1310.       PERFORM S1        ; Execute
  1311.       WRITE S1*"!"              ; Write to log file
  1312.       ENDIF
  1313.    IF NOT NULL S2
  1314.       PERFORM S2        ; Execute
  1315.       WRITE S2*"!"              ; Write to log file
  1316.       ENDIF
  1317.    IF NOT NULL S3
  1318.       PERFORM S3        ; Execute
  1319.       WRITE S3*"!"              ; Write to log file
  1320.       ENDIF
  1321.    GOTO Main            ; And we're done
  1322. ;
  1323. ; ----- Subroutine: Ask for the parameter selection
  1324. ;    S0 returns the selected method # (1-9) or null
  1325. ;
  1326. Ask_Parms:
  1327.    WOPEN  2 10 16 70 (contrast) ASK_ESC
  1328.    ATSAY  2 12 (contrast) " Learn Parms "
  1329.    ATSAY  3 12 (contrast) " 1) 300,E,7,1"
  1330.    ATSAY  4 12 (contrast) " 2) 1200,E,7,1"
  1331.    ATSAY  5 12 (contrast) " 3) 2400,E,7,1"
  1332.    ATSAY  6 12 (contrast) " 4) 4800,E,7,1"
  1333.    ATSAY  7 12 (contrast) " 5) 9600,E,7,1"
  1334.    ATSAY  8 12 (contrast) " 6) 19.2,E,7,1"
  1335.    ATSAY  9 12 (contrast) " 7) 38.4,E,7,1"
  1336.    ATSAY 10 12 (contrast) " 8) 57.6,E,7,1"
  1337.    ATSAY 11 12 (contrast) " 9) 115K,E,7,1"
  1338.  
  1339.    ATSAY  3 28 (contrast) "10) 300,N,7,1"
  1340.    ATSAY  4 28 (contrast) "11) 1200,N,7,1"
  1341.    ATSAY  5 28 (contrast) "12) 2400,N,7,1"
  1342.    ATSAY  6 28 (contrast) "13) 4800,N,7,1"
  1343.    ATSAY  7 28 (contrast) "14) 9600,N,7,1"
  1344.    ATSAY  8 28 (contrast) "15) 19.2,N,7,1"
  1345.    ATSAY  9 28 (contrast) "16) 38.4,N,7,1"
  1346.    ATSAY 10 28 (contrast) "16) 57.6,N,7,1"
  1347.    ATSAY 11 28 (contrast) "18) 115K,N,7,1"
  1348.  
  1349.    ATSAY  3 44 (contrast) "19) Even par."
  1350.    ATSAY  4 44 (contrast) "20) Odd parity"
  1351.    ATSAY  5 44 (contrast) "21) No parity"
  1352.  
  1353.    ATSAY  7 44 (contrast) "22) 7 data bits"
  1354.    ATSAY  8 44 (contrast) "23) 8 data bits"
  1355.  
  1356.    ATSAY 10 44 (contrast) "24) 1 stop bit"
  1357.    ATSAY 11 44 (contrast) "25) 2 stop bits"
  1358.  
  1359.    ATSAY  3 60 (contrast) "26) COM1"
  1360.    ATSAY  4 60 (contrast) "27) COM2"
  1361.    ATSAY  5 60 (contrast) "28) COM3"
  1362.    ATSAY  6 60 (contrast) "29) COM4"
  1363.  
  1364.    ATSAY 12 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  1365.    COMPARMS S0
  1366.    ATSAY 13,12 (contrast) "Current setting: "*S0
  1367.    ATSAY 14 10 (contrast)  "├───────────────────────────────────────────────────────────┤"
  1368.    ATSAY 15 12 (contrast) "Enter selection #:"
  1369.    ATSAY 16 30 (contrast) " Press ESC to cancel "
  1370.  
  1371.    ATGET 15 31 (contrast) 2 S0 ; Read selection
  1372.    WCLOSE
  1373.    RETURN            ; And done
  1374. ;
  1375. ;    Encrypt/decrypt
  1376. ;
  1377. Encrypt:
  1378.    GOSUB Ask_Encrypt        ; Ask for a number
  1379.    SWITCH S0            ; Switch on response in Get_parms
  1380.       CASE "_NULL"              ; No entry
  1381.      SOUND 100,100
  1382.      GOTO Main        ; No action
  1383.       ENDCASE            ; .. no action
  1384.       CASE "1"                  ; DES encrypt
  1385.      S2 = "ENCRYPT"
  1386.      S3 = "DES"
  1387.       ENDCASE
  1388.       CASE "2"                  ; Simple encrypt
  1389.      S2 = "ENCRYPT"
  1390.      S3 = "SIMPLE"
  1391.       ENDCASE
  1392.       CASE "3"                  ; Descrypt
  1393.      S2 = "DECRYPT"
  1394.      S3 = ""                ; No operand
  1395.       ENDCASE
  1396.       DEFAULT
  1397.     SOUND 100,100
  1398.     GOTO Encrypt        ; Repeat request
  1399.       ENDCASE
  1400.    ENDSWITCH
  1401.    ;
  1402.    ;    Ask for the source file
  1403.    ;
  1404. EncrSrc:
  1405.    S1 = "Enter the file to be encrypted/decrypted:"
  1406.    GOSUB Ask_File
  1407.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1408.       GOTO Main
  1409.       ENDIF
  1410.    IF NOT ISFILE S0        ; IF file doesn't exist
  1411.       S0 = "File does not exist: "*S0
  1412.       GOSUB Error
  1413.       GOTO EncrSrc
  1414.       ENDIF
  1415.    S4 = S0            ; Save fname
  1416.    ;
  1417.    ;    Ask for the destination file
  1418.    ;
  1419. EncrDest:
  1420.    S1 = "Name the output of encryption/decryption:"
  1421.    GOSUB Ask_File
  1422.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1423.       GOTO Main
  1424.       ENDIF
  1425.    IF ISFILE S0         ; IF file doesn't exist
  1426.       S0 = "File exists: "*S0&".  Delete it Y/N?"
  1427.       GOSUB Ask_YN
  1428.       IF SUCCESS
  1429.      DELETE S0
  1430.       ELSE
  1431.      GOTO EncrSrc
  1432.      ENDIF
  1433.       ENDIF
  1434.    S5 = S0            ; Save fname
  1435.    ;
  1436.    ;    Ask for the password
  1437.    ;
  1438. EncrPsw:
  1439.    S1 = "Enter the password:"
  1440.    GOSUB Ask_File
  1441.    IF NOT SUCCESS or NULL S0    ; IF ESC'd out
  1442.       GOTO Main
  1443.       ENDIF
  1444.    S6 = S0            ; Save fname
  1445.    ;
  1446.    ;    Execute the command and write to script
  1447.    ;
  1448.    S0 = S2&" S4 S5 S6 "*S3
  1449.    PERFORM S0            ; Execute
  1450.    IF NOT SUCCESS        ; If it failed
  1451.       S0 = "Encrypt/decrypt failed.  Nothing logged to script."
  1452.       GOSUB Error
  1453.       Goto Main
  1454.       ENDIF
  1455.    ;
  1456.    ;    Log an encrypt/decrypt sequence
  1457.    ;
  1458.    WRITE "; Encrypt/decrypt!"
  1459.    WRITE "MESS `"Enter the encrypt/decrypt source: `"!"
  1460.    WRITE "GET S1 60!"
  1461.    WRITE "MESS `"Enter the encrypt/decrypt destination: `"!"
  1462.    WRITE "GET S2 60!"
  1463.    WRITE "MESS `"Enter the encrypt/decrypt password: `"!"
  1464.    WRITE "GET S3 60!"
  1465.    WRITE S2&" S1 S2 S3 "*S3*"!"
  1466.    GOTO Main            ; And we're done
  1467. ;
  1468. ; ----- Subroutine: Ask for the parameter selection
  1469. ;    S0 returns the selected method # (1-9) or null
  1470. ;
  1471. Ask_Encrypt:
  1472.    WOPEN  2 20 8  60 (contrast) ASK_ESC
  1473.    ATSAY  2 22 (contrast) " Learn D/Encrypt "
  1474.    ATSAY  3 22 (contrast) " 1) DES encryption: slow "
  1475.    ATSAY  4 22 (contrast) " 2) Simple encryption: fast"
  1476.    ATSAY  5 22 (contrast) " 3) Decrypt encrypted file"
  1477.  
  1478.    ATSAY  6 20 (contrast)  "├───────────────────────────────────────┤"
  1479.    ATSAY  7 22 (contrast) "Enter selection #:"
  1480.    ATSAY  8 30 (contrast) " Press ESC to cancel "
  1481.  
  1482.    ATGET  7 41 (contrast) 1 S0    ; Read selection
  1483.    WCLOSE
  1484.    RETURN            ; And done
  1485. ;
  1486. ;    Toggle the blank line eater
  1487. ;
  1488. Blnkln:
  1489.    S0 = "SET BSUPPRESS ON"      ; Default as if off
  1490.    IF STRCMP "_BSUP" "ON "      ; Test current setting
  1491.       S0 = "SET BSUPPRESS OFF"  ; Set-up cmd
  1492.       ENDIF
  1493.    PERFORM S0            ; Execute instruction in S0
  1494.    GOSUB StatusLine        ; Update status line
  1495.    GOTO Output            ; And write to output file
  1496. ;
  1497. ;    Toggle the CR/CRLF function (on received CRs)
  1498. ;
  1499. CRLF:
  1500.    S0 = "SET CR CR_LF"          ; Default as if off
  1501.    IF STRCMP "_CRLF" "ON "      ; Test current setting
  1502.       S0 = "SET CR CR"          ; Set-up cmd
  1503.       ENDIF
  1504.    PERFORM S0            ; Execute instruction in S0
  1505.    GOSUB StatusLine        ; Update status line
  1506.    GOTO Output            ; And write to output file
  1507. ;
  1508. ; ----- Subroutine: Draw the basic screen box
  1509. ;
  1510. Screen:
  1511.    DWINDOW CLEAR        ; Clear any window setting
  1512.    CLEAR (default)        ; Clear whole window
  1513.    SSIZE N99            ; Get current screen size
  1514.    DWINDOW N99-12,2 N99-12 77    ; Set kbd scrolling region
  1515.    BOX     N99-13,  0,(N99-11),79 (default)
  1516.  
  1517.    ATSAY 0,0 (default)    ">>───────────────────────────────────────────────────────────────────────────<<"
  1518.    ATSAY 0,      3  (default) " Learn "
  1519.    ATSAY (N99-13),3  (default) " Keyboard "
  1520.    ATSAY N99-11, 28  (default) " ESC to terminate "
  1521.    ATSAY N99-11, 53  (default) " Press F10 for info "
  1522.  
  1523.    ATSAY N99-10,2  (default) "F1 Load accessory         Alt-Q Toggle CR/CRLF      Alt-P   Set comm parms"
  1524.    ATSAY N99- 9,2  (default) "F2 Execute script         Alt-E Toggle echo         Alt-G   Toggle blnkln "
  1525.    ATSAY N99- 8,2  (Default) "F3 Change drive:subdir    Alt-C Clear screen        PgUp    Upload        "
  1526.    ATSAY N99- 7,2  (Default) "F4 Set dft dlo subdir     Alt-L Toggle 25/43        PgDn    Download      "
  1527.    ATSAY N99- 6,2  (Default) "F5 Toggle line/char       Alt-H Hangup              Alt-F10 Shell to DOS  "
  1528.    ATSAY N99- 5,2  (Default) "F6 Toggle learn hold      Alt-D Dial                Alt-0/9 Send macro    "
  1529.    ATSAY N99- 4,2  (Default) "F7 Toggle logging file    Alt-N Encrypt/decrypt     Ctl-End Send break    "
  1530.    ATSAY N99- 3,2  (Default) "F9 Toggle log hold        Alt-Z Toggle masking      Ctl-Prt Toggle print  "
  1531.  
  1532.    GOSUB StatusLine
  1533.    ;
  1534.    ;    Set cursor positions, and we're done
  1535.    ;
  1536.    N95 = 1            ; Receive area row
  1537.    N96 = 0            ; Receive area col
  1538.    N93 = N99-12         ; Kbd area row
  1539.    N94 = 2            ; Kbd area col
  1540.  
  1541.    RETURN
  1542. ;
  1543. ; -----Subroutine: Update the status line
  1544. ;
  1545. StatusLine:
  1546.    IF STRCMP "_DUPL" "HALF"
  1547.       ATSAY N99-2,2  (default) "Echo"
  1548.    ELSE
  1549.       ATSAY N99-2,2  (default) "    "
  1550.       ENDIF
  1551.  
  1552.    IF STRCMP "_MASK" "ON"
  1553.       ATSAY N99-2,8  (default) "Mask"
  1554.    ELSE
  1555.       ATSAY N99-2,8  (default) "    "
  1556.       ENDIF
  1557.  
  1558.    IF STRCMP "_BSUP" "ON "
  1559.       ATSAY N99-2,14 (default) "NoBln"
  1560.    ELSE
  1561.       ATSAY N99-2,14 (default) "     "
  1562.       ENDIF
  1563.  
  1564.    IF STRCMP "_CRLF" "ON "
  1565.       ATSAY N99-2,21 (default) "CR_LF"
  1566.    ELSE
  1567.       ATSAY N99-2,21 (default) "     "
  1568.       ENDIF
  1569.  
  1570.    IF STRCMP "_LOGG" "ON "
  1571.       ATSAY N99-2,28 (default)      "Logging"
  1572.       IF STRCMP "_LOGH" "ON"
  1573.      ATSAY N99-2,37 (default) "Log held"
  1574.       ELSE
  1575.      ATSAY N99-2,37 (default) "        "
  1576.      ENDIF
  1577.    ELSE
  1578.       ATSAY N99-2,28 (default)      "       "
  1579.       ATSAY N99-2,37 (default)      "        "
  1580.       ENDIF
  1581.  
  1582.    IF FLAG(1)
  1583.       ATSAY N99-2,47 (default) "Print"
  1584.    ELSE
  1585.       ATSAY N99-2,47 (default) "     "
  1586.       ENDIF
  1587.  
  1588.    IF FLAG(9)
  1589.       ATSAY N99-2,60 (default) "CharMode"
  1590.    ELSE
  1591.       ATSAY N99-2,60 (default) "LineMode"
  1592.       ENDIF
  1593.  
  1594.    IF FLAG(8)
  1595.       ATSAY N99-2,70 (default) "LearnHeld"
  1596.    ELSE
  1597.       ATSAY N99-2,70 (default) "         "
  1598.       ENDIF
  1599.    RETURN            ; And we're done
  1600. ;
  1601. ; ----- Subroutine: Help
  1602. ;
  1603. Help:
  1604.    WOPEN  0, 0,23,79 (default) HELPESC
  1605.    ATSAY  0, 2 (Default) " Learn Help "
  1606.    ATSAY 23,28 (Default) " Press any key to continue "
  1607. ;
  1608. ;    Help message
  1609. ;
  1610.    ATSAY  1,2 (default) "   The LEARN script creates a script based upon the actions taken.  The"
  1611.    ATSAY  2,2 (default) "function keys that LEARN will recognize and act upon are listed on the main"
  1612.    ATSAY  3,2 (default) "screen.  Each function results in an addition to the script being created,"
  1613.    ATSAY  4,2 (default) "with the exception of Alt-F10 (which allows editing of the script while it"
  1614.    ATSAY  5,2 (default) "is being created... it does not add a SHELL command to the script)."
  1615.    ATSAY  6,2 (default) ""
  1616.    ATSAY  7,2 (default) "   Initially LEARN is in 'line mode'.  When characters (a-z, 1-9) are typed,"
  1617.    ATSAY  8,2 (default) "they echo in the keyboard box.  When RETURN is typed, the whole line is"
  1618.    ATSAY  9,2 (default) "transmitted, and the appropriate script line(s) are written.  The 'mode' may"
  1619.    ATSAY 10,2 (default) "be switched to 'character', where each keystroke is transmitted when it is"
  1620.    ATSAY 11,2 (default) "typed (and each keystroke generates a WAITFOR/TRANSMIT command)."
  1621.    ATSAY 12,2 (default) ""
  1622.    ATSAY 13,2 (default) "NOTE: The display doubles carets and exclamation points.  This is done to"
  1623.    ATSAY 14,2 (default) "allow the the keystroke to correctly transmitted.  Don't be surprised!!"
  1624.    ATSAY 15,2 (default) ""
  1625.    ATSAY 16,2 (default) "   The LEARN script may be put on HOLD with the F6 key.  When held, what"
  1626.    ATSAY 17,2 (default) "is typed is sent, no script is generated, and no functions are available."
  1627.    ATSAY 18,2 (default) ""
  1628.    ATSAY 19,2 (default) "   LEARN does not provide all the functionality of COM-AND.  The basic"
  1629.    ATSAY 20,2 (default) "set of functions required to go on-line are provided.  Additional settings"
  1630.    ATSAY 21,2 (default) "may be added to the output script.  Extensive editing of the output script"
  1631.    ATSAY 22,2 (default) "is recommended in any case."
  1632. ;
  1633. ;    Wait for a keypress, and return
  1634. ;
  1635.    KEYGET S0
  1636.    WCLOSE
  1637.    RETURN
  1638.    ;
  1639.    ;    ESCAPE during this screen
  1640.    ;
  1641. HELPESC:
  1642.    RETURN
  1643. ;
  1644. ; ----- Subroutine: Fatal error.  Open a window, and display a message
  1645. ;    S0 passes the error message(s)
  1646. ;
  1647. Error:
  1648.    WOPEN 10,10,12,70 (contrast) Err_Esc
  1649.    ATSAY 10,12 (contrast) " Learn Error "
  1650.    ATSAY 11,12 (contrast) S0(0:55); Max msg width 55 chars
  1651.    ATSAY 12,26 (contrast) " Press any key to continue "
  1652.    ;
  1653.    ;    Wait a keypress
  1654.    ;
  1655.    KEYGET S0               ; Wait for any key
  1656.    WCLOSE
  1657.    RETURN
  1658.    ;
  1659.    ;    Escape during this screen
  1660.    ;
  1661. Err_Esc:
  1662.    RETURN
  1663. ;
  1664. ; ----- Subroutine: Ask for a script file name
  1665. ;    S1 passes the prompt used
  1666. ;    SUCCESS returns fact script file successfully opened
  1667. ;    S0 returns the fname
  1668. ;
  1669. Ask_File:
  1670.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  1671.    ATSAY 10 12 (contrast) " Learn Fname "
  1672.    ATSAY 11 12 (contrast) S1(0:56)
  1673.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  1674.  
  1675.    ATGET 12 12 (contrast) 54 S0; Read new fname
  1676.    WCLOSE
  1677.    ;
  1678.    ;       Attempt to execute the entry
  1679.    ;
  1680.    LJ S0            ; Left justify
  1681.    S0 = S0 &""                  ; Trim spaces
  1682.    UPPER S0            ; Make pretty
  1683.    IF NOT NULL S0        ; If nothing entered
  1684.       SET SUCCESS ON
  1685.    ELSE
  1686.       SET SUCCESS OFF
  1687.       ENDIF
  1688.    RETURN            ; And done
  1689. ;
  1690. ; ----- Escape during a subwindow
  1691. ;    .. S0 is returned null
  1692. ;
  1693. Ask_Esc:
  1694.    S0 = ""                      ; Make a null return
  1695.    RETURN
  1696. ;
  1697. ; ----- Subroutine: Ask a question and take a y/n answer
  1698. ;    S0 passes the text to be displayed
  1699. ;    SUCCESS returns fact of y/n
  1700. ;
  1701. Ask_YN:
  1702.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  1703.    ATSAY 10 12 (contrast) " Learn Y/N "
  1704.    ATSAY 11 12 (contrast) S0(0:55)
  1705.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  1706.  
  1707.    ATGET 12 12 (contrast) 1 S0 ; Read y/n
  1708.    WCLOSE
  1709.    ;
  1710.    ;       Interperet the response
  1711.    ;
  1712.    IF NULL S0 or FIND S0 "Y"    ; If c/r yes
  1713.       SET SUCCESS ON
  1714.    ELSE
  1715.       SET SUCCESS OFF
  1716.       ENDIF
  1717.    RETURN            ; And done
  1718. ;
  1719. ; ----- Subroutine: Write a line (in S0) to the output file
  1720. ;
  1721. WriteLn:
  1722.    WRITE S0            ; Write to file
  1723.    WRITE "!" 1                  ; Add a crlf
  1724.    RETURN            ; And continue
  1725. ;
  1726. ; ----- Subroutine: Write initial settings out to the output file
  1727. ;
  1728. Initial:
  1729.    ;
  1730.    ;    Comments
  1731.    ;
  1732.    IF CONNECTED
  1733.       S0 = "; -------------------------------------------------------"
  1734.       GOSUB WriteLn
  1735.       S0 = "; WARNING: This script learned after connection was made " *"_Date"
  1736.       GOSUB WriteLn
  1737.       S0 = "; ------------------------------------------------------- "
  1738.       GOSUB WriteLn
  1739.       GOTO No_Init
  1740.       ENDIF
  1741.    ;
  1742.    ;    Save initial settings
  1743.    ;
  1744.    S0 = "; Initial state: "*"_Date"
  1745.    GOSUB WriteLn
  1746.    S0 = "SET DUPLEX "*"_DUPL"
  1747.    GOSUB WriteLn
  1748.    S0 = "EMULATE "*"_EMUL"
  1749.    GOSUB WriteLn
  1750.    S0 = "SET 25"
  1751.    IF GT "_SSIZ" 25
  1752.       S0 = "SET 43"
  1753.       ENDIF
  1754.    GOSUB WriteLn
  1755.    S0 = "SET MASK "*"_MASK"
  1756.    GOSUB WriteLn
  1757.    S0 = "SET CR CR_LF"
  1758.    IF STRCMP "_CRLF" "OFF"
  1759.       S0 = "SET CR CR"
  1760.       ENDIF
  1761.    GOSUB WriteLn
  1762.    ;
  1763.    ;    Save current comm parameters
  1764.    ;
  1765.    COMPARM S1
  1766.    S0 = "SET PORT "*S1(11:14)
  1767.    GOSUB WriteLn
  1768.    S0 = "SET BAUD "*S1(0:3)
  1769.    GOSUB WriteLn
  1770.    IF STRCMP S1(5:5) "E"
  1771.       S0 = "SET PARITY EVEN"
  1772.    ELSE
  1773.       IF STRCMP S1(5:5) "O"
  1774.      S0 = "SET PARITY ODD"
  1775.       ELSE
  1776.      S0 = "SET PARITY NONE"
  1777.      ENDIF
  1778.       ENDIF
  1779.    GOSUB WriteLn
  1780.    S0 = "SET DATA "*S1(7:7)
  1781.    GOSUB WriteLn
  1782.    S0 = "SET STOP "*S1(9:9)
  1783.    GOSUB WriteLn
  1784.    ;
  1785.    ;    Final comment to start learned portion
  1786.    ;    .. and a few settings that might be desired on/off line
  1787.    ;
  1788. No_Init:
  1789.    S0 = "; Learned script"
  1790.    GOSUB WriteLn
  1791.    S0 = "LEGEND `"Script learned: `"*`""*"_Date"*"`""
  1792.    GOSUB WriteLn
  1793.    IF FLAG(1)
  1794.       S0 = "PRINTER ON"
  1795.    ELSE
  1796.       S0 = "PRINTER OFF"
  1797.       ENDIF
  1798.    GOSUB WriteLn
  1799.    S0 = "SET CHAT "*"_CHAT"
  1800.    GOSUB WriteLn
  1801.    S0 = "SET KBDB "*"_KBDB"
  1802.    GOSUB WriteLn
  1803.    RETURN
  1804.