home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Share Gallery 1
/
share_gal_1.zip
/
share_gal_1
/
CO
/
CO029B.ZIP
/
CA28-3.ZIP
/
LEARN.SRC
< prev
next >
Wrap
Text File
|
1991-04-18
|
49KB
|
1,804 lines
SET TTHRU OFF ; Make first to allow typeahead
S19 = "Learn ver 1.0 " ; 20 chars long
; ----- Learn: Learn mode shell for COM-AND
;
; R.McG; 8/89, Chicago
; ----------------------------------------------------------------
; Usages:
; S19 -----> Legend line
; S18 -----> Load-time drive:subdirectory (for exit)
; S17 -----> Load-time download d:subdir (for exit)
; S16 -----> Output file name
; S12 -----> Text before last line displayed to screen
; S11 -----> Last line displayed to screen
; S10 -----> Current output buffer
;
; N99 -----> Number of lines on screen
; N96 -----> Current receive area cursor
; N95 -----> Current receive area cursor
; N94 -----> Current Kbd area cursor
; N93 -----> Current Kbd area cursor
; N92 -----> Saved cursor on entry
; N91 -----> Saved cursor on entry
; N90 -----> Current output buffer index
;
; FLAG(0) -> Off: learning, on: ready to terminate
; FLAG(1) -> Off: no printer on: Printer in use
; FLAG(2) -> Off: log not used on: Log was used
; FLAG(8) -> Off: learning, on: learning suspended
; FLAG(9) -> Off: in line mode, on: in character mode
; -----------------------------------------------------------------------
;
; Initialization
;
CURSOR N91,N92 ; Read current cursor
LEGEND S19 ; Set initial legend
SUBDIR S18 ; Read current subdir
DLDIR S17 ; Read current download subdir
SSIZE N99 ; Get current screen size
SAVE 0,0,N99-2,79 ; Save original screen
ON ESCAPE GOSUB ESCAPE ; Escape action
SET FLAG(1) OFF ; Set printer on/off flag
IF STRCMP "_PRIN" "ON" ; .. as we only turn printer on
SET FLAG(1) ON ; .. during receive portion
PRINTER OFF ; Turn printer off unconditionally
ENDIF
;
; Ask for an output file name
;
Get_Output:
S1 = "Enter a file name to be output:"
GOSUB Ask_File ; Ask for an output file
IF NOT SUCCESS EXIT ; If ESC'd then stop
S16 = S0 ; Save fname
;
; Test for file existing
;
IF ISFILE S16 ; If file exists
S0 = S16 *" already exists. Overwrite it? Y/N (cr=no)"
GOSUB Ask_YN
IF NOT SUCCESS GOTO Get_Output
ENDIF
;
; Open the output file, no append
;
FOPENO S16 TEXT ; Open output file
IF NOT SUCCESS
S0 = "Error opening output file: "*S16
GOSUB Error ; Report
GOTO Get_output
ENDIF
;
; Perform other initialization
;
GOSUB Initial ; Save initial settings
SET CHAT OFF ; Turn off chat
GOTO START ; And continue
;
; ----- Subroutine: Escape - Set a flag for mainline loop
;
Escape:
SET FLAG(0) ON ; Flag fact
RETURN ; And continue
;
;------ Subroutine: Terminate the all LEARN script activity
;
End_Learn:
DWINDOW CLEAR ; Clear display window
IF FLAG(2) and STRCMP "_LOGG" "ON "
WRITE "LOG CLOSE!" ; FInish logging if on and turned on within
LOG CLOSE
ENDIF
WRITE "^Z" 2 ; Terminate w/EOF
FCLOSEO ; Close output file
SET DLDIR S17 ; Reset DLDIR to load time
CHDIR S18 ; Reset default subdir to load time
RESTORE ; Restore screen
LOCATE N91,N92 ; Restore cursor
IF FLAG(1) ; Set printer according to current state
PRINTER ON
ELSE
PRINTER OFF
ENDIF
RETURN ; Rtn to caller
;
;------ Subroutine: Ask if Exit to be taken
;
Exit:
S0 = "Do you wish to terminate LEARN? Enter Y to terminate."
GOSUB Ask_YN
IF SUCCESS ; IF answer is 'y'
GOSUB End_Learn ; Terminate
EXIT ; And stop script
ENDIF
SET FLAG(0) OFF ; Clear ESC flag
RETURN ; And continue
;
; ----- Main-line: Draw the screen, and begin loop
;
Start:
N90 = 0 ; Initialize buffer index
S11 = "" ; Init last line received
S12 = "" ; Init next ot last line received
SET FLAG(0) OFF ; Init ESC hit flag
SET FLAG(9) OFF ; Init to line mode
SET FLAG(8) OFF ; Init to not held
GOSUB Screen ; Draw screen
LOCATE 1,1 ; Set cursor
DWINDOW N99-12,2 N99-12 77 ; Set kbd scrolling region
GOTO Main
;
; Write a line (in S0, less CRLF) to the output file
;
Output:
WRITE S0 ; Write to file
WRITE "!" ; Add a crlf
;
; Display received text, and wait for a keypress
;
Main:
LOCATE N93,N94 ; Set kbd cursor
IF FLAG(0) GOSUB Exit ; If ESC pressed, ask if to exit
IF NOT HITKEY ; If nothig on kbd
IF RECEIVE GOSUB Receive ; Allow incoming text to be displayed
GOTO Main
ENDIF
;
; We have a keypress pending
;
KEYGET S1 ; Read a single key
LENG S1 N0 ; Compute length of KEYGET
SWITCH N0
CASE 1 ; length = 1
GOTO ASCII
ENDCASE
CASE 2 ; length = 2
GOTO CONTROL
ENDCASE
CASE 4 ; length = 4
GOTO FUNCTION
ENDCASE
ENDSWITCH
GOTO Main ; And continue
;
; Update the keyboard display
;
KbdDisp:
IF GT N90 0
S0 = S10(0:n90-1) ; COpy current buffer
PRESERVE S0 ; Make displayable
ATSAY N99-12,2 (Default) S0 *" "
ENDIF
N94=N90+2 ; Set new col #
GOTO Main
;
; ----- Subroutine: Handle receipt of text
;
Receive:
DWINDOW 1, 0,(N99-14),79 ; Set rcv scrolling region
IF FLAG(1) PRINTER ON ; Turn on printer while reading comm
LOCATE N95,N96 ; Set rcv cursor
S12 = S11 ; Save previous line read
RGET S11 80 1 ; Read new text, max wait 1 sec
CURSOR N95,N96 ; Read new rcv area cursor
IF FLAG(1) PRINTER OFF ; Turn off printer now
DWINDOW N99-12,2 N99-12,77 ; Set kbd scrolling region
RETURN
;
; ASCII char entered: length in N0 is 1
;
ASCII:
IF FLAG(8) ; If learn held
PRESERVE S1 ; ..
TRANSMIT S1 ; Send the char
GOTO Main ; .. and no more
ENDIF
;
; Catch buffer overflow (limit kbd buffer to 60 chars)
;
IF GT (N90+2) 60
SOUND 100,100
GOTO Main
ENDIF
;
; Buffer the char (preserving for TRANSMIT)
;
S10(N90:N90) = S1 ; Buffer keystroke
INC N90
IF STRCMP S1 "!" or STRCMP S1 "^"
S10(N90:N90) = S1 ; DOuble special chars to PRESERVE for TRANSMIT
INC N90
ENDIF
;
; If CHAR mode, send immediate
;
IF FLAG(9) GOTO Transmit ; If char mode transmit immediately
GOTO KbdDisp ; Update kbd display
;
; Handle control chars: length in N0 is 2
;
Control:
S0 = "0x"*S1 ; Make hex form of #
N0 = S0 ; If ctl char (e.g. 0d for c/r)
N0 = N0+64 ; Convert to ASCII @,A,B,...
S0 = "^" ; Store delimiter
ITOC N0 S0(1:1) ; Store char being ctl'd
;
; Simply xmit if LEARN HELD
;
IF FLAG(8) ; If learn held
TRANSMIT S0 ; Send the char
GOTO Main ; .. and no more
ENDIF
;
; Catch special control chars
;
IF (NOT FLAG(9)) and STRCMP S1 "08" ; Catch backspace here
GOTO Backspace ; .. in line mode
ENDIF
IF STRCMP S1 "0D" ; Catch c/rs
GOTO RETURN ; .. in either line or char mode
ENDIF
IF GT (N90+2) 60 ; Handle buffer overflow here
SOUND 100,100
GOTO Main
ENDIF
;
; Buffer the remainder as "^" chars
;
S10(N90:N90+1) = S0(0:1) ; Store delimiter
N90 = N90+2
IF FLAG(9) GOTO Transmit ; If char mode transmit directly
GOTO KbdDisp ; Update kbd display
;
; Backspace entered
;
Backspace:
IF ZERO N90
GOTO KbdDisp
ENDIF
DEC N90
IF STRCMP S10(N90-1:N90-1) "^" or STRCMP S10(N90-1:N90) "!!"
DEC N90
ENDIF
GOTO KbdDisp ; Update kbd display
;
; Carriage return entered
;
Return:
IF NOT ZERO N90
S10 = S10(0:N90-1)*"!"
ELSE
S10 = "!"
ENDIF
N90 = N90+1
;
; Execute the current buffer
;
Transmit:
GOSUB Waitfor ; Emit a WAITFOR
;
; Now, emit a TRANSMIT statement
;
WRITE "TRANSMIT `"" ; Write TRANSMIT statement
IF STRCMP S10(N90-1:N90-1) "!!"
WRITE S10 N90-1 ; Write string to be xmitted less final c/r
WRITE "!!" 2 ; .. adding c/r after conversion
ELSE
WRITE S10 N90 ; Write string as-is
ENDIF
WRITE "`"!" ; .. finish the quoted string, and add a c/r
;
; Perform the TRANSMIT and cleanup
;
TRANSMIT S10(0:N90-1)
N90 = 0 ; Zero index to kbd buffer
CLEAR (default) ; Clear kbd scrolling region
N94 = 2 ; Set cursor col
GOTO Main
;
; ----- Subroutine: Emit a WAITFOR
;
Waitfor:
LJ S11 ; Left justify last text rcvd
S11 = S11&"" ; Trim trailing spaces
LENGTH S11 N1 ; Length of last text rcvd
IF NOT ZERO N1 ; If a prompt (non null) was received
S0 = S11 ; Replicate
GOTO EmitWait ; And emit a WAITFOR
ENDIF
;
; Nothing received last... look at previous receipt
;
LJ S12 ; Left justify
S12 = S12&"" ; Trim trailing spaces
LENGTH S12 N1 ; length of text received prior to last
IF NOT ZERO N1 ; If a prompt (non null) was received
S0 = S12 ; Replicate
GOTO EmitWait ; And emit a WAITFOR
ENDIF
;
; Last 2 lines received were empty.
;
WRITE ";!" ; Write a comment line
WRITE "; WAITFOR may be needed here!"
WRITE ";!" ; Write a comment line
RETURN
;
; Emit a WAITFOR using the value in S0
;
EmitWait:
PRESERVE S0 ; Save carets/bangs
LENGTH S0 N1 ; Compute new length
WRITE "WAITFOR `"" ; Write WAITFOR
WRITE S0 ; Write string to be awaited
WRITE "`"!" ; .. finish the quoted string, and add a c/r
WRITE ";*IF NOT WAITFOR GOTO ...!"
S11 = "" ; Clear last receipt
S12 = "" ; ..
RETURN
;
; Function key entered
;
Function:
IF FLAG(8) and NOT STRCMP S1 "4000"
SOUND 100,100 ; Disallow if LEARN HELD
GOTO Main ; .. and not the HOLD key
ENDIF
;
; Interpret the char
;
SWITCH S1
CASE "2E00" ; Alt-C
GOTO Clear
ENDCASE
CASE "1200" ; Alt-E
GOTO Echo
ENDCASE
CASE "2C00" ; Alt-Z
GOTO Mask
ENDCASE
CASE "2600" ; Alt-L
GOTO ScrSize
ENDCASE
CASE "2300" ; Alt-H
GOTO Hangup
ENDCASE
CASE "2000" ; Alt-D
GOTO Dial
ENDCASE
CASE "1900" ; Alt-P
GOTO Parms
ENDCASE
CASE "3100" ; Alt-N
GOTO Encrypt
ENDCASE
CASE "2200" ; Alt-G
GOTO Blnkln
ENDCASE
CASE "1000" ; Alt-Q
GOTO CRLF
ENDCASE
CASE "7500" ; Ctl-End
GOTO Break
ENDCASE
CASE "7200" ; Ctl-PrtSc
GOTO Printer
ENDCASE
CASE "4900" ; PgUp
GOTO Upload
ENDCASE
CASE "5100" ; PgDn
GOTO Download
ENDCASE
CASE "7800" ; Alt-1
GOTO Alt_1
ENDCASE
CASE "7900" ; Alt-2
GOTO Alt_2
ENDCASE
CASE "7A00" ; Alt-3
GOTO Alt_3
ENDCASE
CASE "7B00" ; Alt-4
GOTO Alt_4
ENDCASE
CASE "7C00" ; Alt-5
GOTO Alt_5
ENDCASE
CASE "7D00" ; Alt-6
GOTO Alt_6
ENDCASE
CASE "7E00" ; Alt-7
GOTO Alt_7
ENDCASE
CASE "7F00" ; Alt-8
GOTO Alt_8
ENDCASE
CASE "8000" ; Alt-9
GOTO Alt_9
ENDCASE
CASE "8100" ; Alt-0
GOTO Alt_0
ENDCASE
CASE "3B00" ; F1
GOTO Accessry
ENDCASE
CASE "3C00" ; F2
GOTO Script
ENDCASE
CASE "3D00" ; F3
GOTO Chdir
ENDCASE
CASE "3E00" ; F4
GOTO DlDir
ENDCASE
CASE "3F00" ; F5
GOTO LineChar
ENDCASE
CASE "4000" ; F6
GOTO Hold
ENDCASE
CASE "4100" ; F7
GOTO Log
ENDCASE
CASE "4300" ; F9
GOTO LogHold
ENDCASE
CASE "4400" ; F10
GOSUB Help ; Note uncharacteristic GOSUB
ENDCASE
CASE "7100" ; Alt-F10
GOTO Shell
ENDCASE
;
; Other keypresses are unrecognized
;
DEFAULT
SOUND 100,100 ; Signal error
ENDCASE
ENDSWITCH
GOTO Main ; And continue
;
; Shell to DOS (for convenience only. SHELL is not written
; .. to the learned script
;
SHELL:
S16 = "_OFILE" ; Save output fname
FCLOSEO ; Close output file
DWINDOW Clear ; Clear for implicit save
SHELL ; Shell to DOS
DWINDOW N99-12,2 N99-12 77 ; ReSet kbd scrolling region
LEGEND S19 ; ReSet legend
FOPENO S16 TEXT APPEND ; Allow edits during shell
GOTO Main
;
; Clear the screen
;
Clear:
DWINDOW 1, 0,(N99-14),79 ; Set rcv scrolling region
CLEAR (default) ; Perform the clear function
CURSOR N95,N96 ; Set new cursor
DWINDOW N99-12,2 N99-12,77 ; Set kbd scrolling region
LOCATE N93,N94 ; Set kbd cursor
S0 = "CLEAR" ; Set-up the line to add to output
GOTO Output ; Set-up the line to add to output
;
; Toggle echo
;
Echo:
S0 = "SET DUPLEX HALF" ; Default as if full
IF STRCMP "_DUPL" "HALF" ; Test current setting
S0 = "SET DUPLEX FULL" ; Set-up cmd and output
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine
GOTO Output ; Set-up the line to add to output
;
; Toggle mask
;
Mask:
S0 = "SET MASK ON" ; Default as if off
IF STRCMP "_MASK" "ON " ; Test current setting
S0 = "SET MASK OFF" ; Set-up cmd and output
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine
GOTO Output ; Set-up the line to add to output
;
; Toggle screen size
;
ScrSize:
S0 = "SET 43"
IF GT "_SSIZ" 25
S0 = "SET 25"
ENDIF
PERFORM S0 ; Execute instruction in S0
SSIZE N99 ; Get current screen size
GOSUB Screen ; Redraw the screen
GOTO Output ; Set-up the line to add to output
;
; Send a macro
;
Alt_0:
S0 = "MACRO 0"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_1:
S0 = "MACRO 1"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_2:
S0 = "MACRO 2"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_3:
S0 = "MACRO 3"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_4:
S0 = "MACRO 4"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_5:
S0 = "MACRO 5"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_6:
S0 = "MACRO 6"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_7:
S0 = "MACRO 7"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_8:
S0 = "MACRO 8"
GOTO Send_Macro ; Set-up the line to add to output
;
; Send a macro
;
Alt_9:
S0 = "MACRO 9"
;
; Finally, for all the above, send it
;
Send_Macro:
PERFORM S0 ; Execute instruction in S0
GOTO Output ; Set-up the line to add to output
;
; Hangup
;
Hangup:
GOSUB Waitfor ; Emit waitfor
S0 = "HANGUP"
PERFORM S0 ; Execute instruction in S0
GOTO Output ; Set-up the line to add to output
;
; Send a break
;
Break:
GOSUB Waitfor ; Emit waitfor
S0 = "BREAK"
PERFORM S0 ; Execute instruction in S0
GOTO Output ; Set-up the line to add to output
;
; Toggle printer
;
Printer:
IF FLAG(1) ; Test flagged state
S0 = "PRINTER OFF" ; .. If set printer is ON during rcv
SET FLAG(1) OFF
ELSE ; Else its off now
S0 = "PRINTER ON"
SET FLAG(1) ON
ENDIF
WRITE S0*"!" ; LOG instruction in S0
GOSUB StatusLine
GOTO Main ; Set-up the line to add to output
;
; Toggle line/char mode
;
LineChar:
IF FLAG(9)
SET FLAG(9) OFF
ELSE
SET FLAG(9) ON
ENDIF
GOSUB StatusLine
GOTO Main
;
; Toggle learn hold
;
Hold:
IF FLAG(8)
SET FLAG(8) OFF
ELSE
SET FLAG(8) ON
ENDIF
GOSUB StatusLine ; Update status line
GOTO Main
;
; ----- Subroutine: Upload current file
;
UpLoad:
GOSUB Ask_Method
S1 = "/NONAME/" ; Make file name null
SWITCH S0
CASE "_NULL" ; No entry
SOUND 100,100
GOTO Main ; No action
ENDCASE ; .. no action
CASE "1" ; WXMODEM
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE WXMODEM S1"
ENDCASE
CASE "2" ; XMODEM
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE XMODEM S1"
ENDCASE
CASE "3" ; ASCII
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE ASCII S1"
ENDCASE
CASE "4" ; YMODEM/XMODEM1K
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE YMODEM S1"
ENDCASE
CASE "5" ; CISB
S0 = "SENDFILE CISB"
ENDCASE
CASE "6" ; QuickB
S0 = "SENDFILE QuickB"
ENDCASE
CASE "7" ; KERMIT
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE KERMIT S1"
ENDCASE
CASE "8" ; Batch YMODEM
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE BYMODEM S1"
ENDCASE
CASE "9" ; Batch YMODEM-G
GOSUB Ask_Name ; Ask for fname in S1
S0 = "SENDFILE BYMOG S1"
ENDCASE
DEFAULT
SOUND 100,100
GOTO Main ; No action
ENDCASE
ENDSWITCH
;
; If we have a valid file name, perform it
;
Transfer:
IF NULL S1 ; Catch failed Ask_Name
GOTO Main
ENDIF
PERFORM S0
IF NOT STRCMP S1 "/NONAME/"
WRITE "; File transfer!"
WRITE "MESS `"Enter the file name: `"!"
WRITE "GET S1 60!"
ENDIF
GOTO Output ; LOG the file name too
;
; ----- Subroutine: Upload current file
;
DownLoad:
GOSUB Ask_Method
S1 = "/NONAME/" ; Make file name null
SWITCH S0
CASE "_NULL" ; No entry
SOUND 100,100
GOTO Main ; No action
ENDCASE ; .. no action
CASE "1" ; WXMODEM
GOSUB Ask_Name ; Ask for fname in S1
S0 = "GETFILE WXMODEM S1"
ENDCASE
CASE "2" ; XMODEM
GOSUB Ask_Name ; Ask for fname in S1
S0 = "GETFILE XMODEM S1"
ENDCASE
CASE "3" ; ASCII
GOSUB Ask_Name ; Ask for fname in S1
S0 = "GETFILE ASCII S1"
ENDCASE
CASE "4" ; YMODEM/XMODEM1K
GOSUB Ask_Name ; Ask for fname in S1
S0 = "GETFILE YMODEM S1"
ENDCASE
CASE "5" ; CISB
S0 = "GETFILE CISB"
ENDCASE
CASE "6" ; QuickB
S0 = "GETFILE QuickB"
ENDCASE
CASE "7" ; KERMIT
S0 = "GETFILE KERMIT"
ENDCASE
CASE "8" ; Batch YMODEM
S0 = "GETFILE BYMODEM"
ENDCASE
CASE "9" ; Batch YMODEM-G
S0 = "GETFILE BYMOG"
ENDCASE
DEFAULT
SOUND 100,100
GOTO Main ; No action
ENDCASE
ENDSWITCH
GOTO Transfer
;
; ----- Subroutine: Ask for the upload method
; S0 returns the selected method # (1-9) or null
; S12 returns the from file name
;
Ask_Method:
WOPEN 2 20 14 60 (contrast) ASK_ESC
ATSAY 2 22 (contrast) " Learn UpLoad/Download "
ATSAY 3 22 (contrast) " 1) Windowed XMODEM"
ATSAY 4 22 (contrast) " 2) CRC/Checksum XMODEM"
ATSAY 5 22 (contrast) " 3) ASCII transfer "
ATSAY 6 22 (contrast) " 4) YMODEM/XMODEM-1K"
ATSAY 7 22 (contrast) " 5) CIS-B "
ATSAY 8 22 (contrast) " 6) CIS Quick-B "
ATSAY 9 22 (contrast) " 7) Kermit "
ATSAY 10 22 (contrast) " 8) Batch YMODEM "
ATSAY 11 22 (contrast) " 9) Batch YMODEM-G "
ATSAY 12 20 (contrast) "├───────────────────────────────────────┤"
ATSAY 13 22 (contrast) "Enter method #:"
ATSAY 14 30 (contrast) " Press ESC to cancel "
ATGET 13 48 (contrast) 1 S0 ; Read new fname
WCLOSE
RETURN ; And done
;
; ----- Subroutine: Ask for a up/down file name
; SUCCESS returns fact script file successfully opened
; S1 returns the fname
;
Ask_Name:
WOPEN 10 10 13 70 (contrast) NAMEESC
ATSAY 10 12 (contrast) " Learn Up/Down Filename "
ATSAY 11 12 (contrast) "Enter a file name to be transferred:"
ATSAY 13 30 (contrast) " Press ESC to cancel "
ATGET 12 12 (contrast) 54 S1; Read new fname
WCLOSE
;
; Attempt to execute the entry
;
LJ S1 ; Left justify
S1 = S1&"" ; Trim spaces
RETURN ; And done
NAMEESC:
S1 = ""
RETURN
;
; Dial a number
;
Dial:
GOSUB Ask_Dial ; Get dial dir #
IF NOT SUCCESS or NULL S2 ; IF ESC'd out
GOTO Main
ENDIF
DIAL S2 ; Try to dial #
IF FAILED
GOTO Main
ENDIF
;
; Write a DIAL paragraph to the output file
;
WRITE "; Dialing!"
WRITE "IF NOT LINKED!"
WRITE " DIAL `""
WRITE S2
WRITE "`"!"
WRITE " IF FAILED EXIT!"
WRITE " ENDIF!"
GOTO Main ; LOG the file name too
;
; ----- Subroutine: Ask for the number to dial
; S2 returns the selected entry # or null
;
Ask_Dial:
N0 = 0 ; Page #
WOPEN 2 20 15 60 (contrast) ASK_ESC
ATSAY 2 22 (contrast) " Learn Dial "
ATSAY 13 20 (contrast) "├───────────────────────────────────────┤"
ATSAY 14 22 (contrast) "Enter entry #:"
ATSAY 15 30 (contrast) " Press ESC to cancel "
;
; Display the current page
;
Dial_Loop:
SCROLL 0, 3,22 12,58 (contrast) ; Clear display area
FOR N1 = 1,10
N4 = N0+N1
DIRECTORY S0 N4
ATSAY (2+N1) 22 (contrast) N4*")"
ATSAY (2+N1) 27 (contrast) S0
ENDFOR
LOCATE 14 37
N2 = 37 ; Currnt cursor
S2 = "" ; Clear save buffer
;
; Wait for a keypress
;
Dial_Key:
KEYGET S0 ; Read keypress
LENGTH S0 N1
SWITCH N1 ; Switch on length
CASE 1 ; Len = 1: ASCII char
IF NOT FIND "+-@#0123456789" S0
SOUND 100,100
GOTO Dial_Key
ENDIF
S2 = S2*S0 ; Save the keypress
ATSAY 14 N2 (contrast) S0
INC N2 ; Increment cursor
LOCATE 14 N2
GOTO Dial_Key
ENDCASE
CASE 2 ; Len = 2: ctl char
SWITCH S0 ; Handle individual ctl chars
CASE "0D" ; Carriage rtn
SET SUCCESS ON
GOTO DIAL_End
ENDCASE
CASE "08" ; Carriage rtn
LENGTH S2 N0
IF GT N0 1
S2 = S2(0:N0-2)
DEC N2 ; Increment cursor
LOCATE 14 N2
ATSAY 14 N2 (contrast) " "
ELSE
S2 = "" ; Clear field so far
N2 = 37
ATSAY 14 N2 (contrast) " "
ENDIF
GOTO Dial_Key
ENDCASE
DEFAULT ; Any other ctl char
SOUND 100,100
GOTO Dial_Key
ENDCASE
ENDSWITCH
ENDCASE ; End len = 2
CASE 4
SWITCH S0 ; Len = 4: Ftn key
CASE "4900" ; PgUp
N0 = N0-10
IF LT N0 0
N0 = 90
ENDIF
GOTO Dial_Loop
ENDCASE
CASE "5100" ; PgDn
N0 = N0+10
IF GE N0 100
N0 = 0
ENDIF
GOTO Dial_Loop
ENDCASE
CASE "4700" ; Home
N0 = 0
GOTO Dial_Loop
ENDCASE
CASE "4F00" ; End
N0 = 90
GOTO Dial_Loop
ENDCASE
DEFAULT ; Any other ftn keyr
SOUND 100,100
GOTO Dial_Key
ENDCASE
ENDSWITCH
ENDCASE
DEFAULT ; Len <> 1,2,4... e.g. esc
SET SUCCESS OFF
ENDCASE
ENDSWITCH
Dial_End:
WCLOSE
RETURN ; And done
;
; Load an accessory
;
Accessry:
GOSUB Ask_AccNum ; Get acc dir #
IF NOT SUCCESS or NULL S2 ; IF ESC'd out
GOTO Main
ENDIF
S0 = "WARNING: An accessory ends LEARN. Enter Y to proceed."
GOSUB Ask_YN
IF NOT SUCCESS ; IF ESC'd out
GOTO Main
ENDIF
;
; Write an ACC paragraph to the output file
;
WRITE "; Accessory!"
WRITE "ACCESSORY `""
LENGTH S2 N2
WRITE S2 N2
WRITE "`"!"
GOSUB End_Learn ; Terminate output
;
; And execute the accessory
;
ACCESSORY S2 ; Load accessory
Dummy1:
GOTO Main ; Branch if EXECUTE fails
;
; ----- Subroutine: Ask for the entry number to execute
; S2 returns the selected entry # or null
;
Ask_AccNum:
N0 = 0 ; Page #
WOPEN 2 10 15 70 (contrast) ASK_ESC
ATSAY 2 12 (contrast) " Learn Accessory "
ATSAY 13 10 (contrast) "├───────────────────────────────────────────────────────────┤"
ATSAY 14 12 (contrast) "Enter entry #:"
ATSAY 15 20 (contrast) " Press ESC to cancel "
;
; Display the current page
;
Acc_Loop:
SCROLL 0, 3,12 12,68 (contrast) ; Clear display area
FOR N1 = 1,10
N4 = N0+N1
ANAME S0 N4
ATSAY (2+N1) 12 (contrast) N4*")"
ATSAY (2+N1) 17 (contrast) S0
ENDFOR
LOCATE 14 27
N2 = 27 ; Currnt cursor
S2 = "" ; Clear save buffer
;
; Wait for a keypress
;
Acc_Key:
KEYGET S0 ; Read keypress
LENGTH S0 N1
SWITCH N1 ; Switch on length
CASE 1 ; Len = 1: ASCII char
IF NOT FIND "0123456789" S0
SOUND 100,100
GOTO Acc_Key
ENDIF
S2 = S2*S0 ; Save the keypress
ATSAY 14 N2 (contrast) S0
INC N2 ; Increment cursor
LOCATE 14 N2
GOTO Acc_Key
ENDCASE
CASE 2 ; Len = 2: ctl char
SWITCH S0 ; Handle individual ctl chars
CASE "0D" ; Carriage rtn
SET SUCCESS ON
GOTO Acc_End
ENDCASE
CASE "08" ; Carriage rtn
LENGTH S2 N0
IF GT N0 1
S2 = S2(0:N0-2)
DEC N2 ; Increment cursor
LOCATE 14 N2
ATSAY 14 N2 (contrast) " "
ELSE
S2 = "" ; Clear field so far
N2 = 27
ATSAY 14 N2 (contrast) " "
ENDIF
GOTO Acc_Key
ENDCASE
DEFAULT ; Any other ctl char
SOUND 100,100
GOTO Acc_Key
ENDCASE
ENDSWITCH
ENDCASE ; End len = 2
CASE 4
SWITCH S0 ; Len = 4: Ftn key
CASE "4900" ; PgUp
N0 = N0-10
IF LT N0 0
N0 = 40
ENDIF
GOTO Acc_Loop
ENDCASE
CASE "5100" ; PgDn
N0 = N0+10
IF GE N0 50
N0 = 0
ENDIF
GOTO Acc_Loop
ENDCASE
CASE "4700" ; Home
N0 = 0
GOTO Acc_Loop
ENDCASE
CASE "4F00" ; End
N0 = 40
GOTO Acc_Loop
ENDCASE
DEFAULT ; Any other ftn keyr
SOUND 100,100
GOTO Acc_Key
ENDCASE
ENDSWITCH
ENDCASE
DEFAULT ; Len <> 1,2,4... e.g. esc
SET SUCCESS OFF
ENDCASE
ENDSWITCH
Acc_End:
WCLOSE
RETURN ; And done
;
; Load a script
;
Script:
S1 = "Enter the script file name:"
GOSUB Ask_File ; Get script file name
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
S2 = S0 ; Save fname
IF NOT ISSCFILE S2 ; Test for presence
S0 = "Script file not found: "*S2
GOSUB Error
GOTO Script
ENDIF
;
; Warn termination
;
S0 = "WARNING: A script call ends LEARN. Enter Y to proceed."
GOSUB Ask_YN
IF NOT SUCCESS ; IF ESC'd out
GOTO Main
ENDIF
;
; Write a script paragraph to the output file
;
WRITE "; Script!"
WRITE "EXECUTE `""
WRITE S2
WRITE "`"!"
GOSUB End_Learn ; Terminate output
;
; And execute the script
;
EXECUTE S2 ; Load accessory
Dummy2:
GOTO Main ; Branch if EXECUTE fails
;
; Change drive:subdir
;
Chdir:
S1 = "Enter the new drive:subdirectory:"
GOSUB Ask_File ; Get script file name
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
S0 = "CHDIR `""*S0&"`""
PERFORM S0 ; Execute instruction in S0
GOTO Output ; Set-up the line to add to output
;
; Change default dload drive:subdir
;
DlDir:
S1 = "Enter the new download drive:subdirectory:"
GOSUB Ask_File ; Get script file name
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
S0 = "SET DLDIR `""*S0&"`""
PERFORM S0 ; Execute instruction in S0
GOTO Output ; Set-up the line to add to output
;
; Toggle the log function
;
Log:
IF STRCMP "_LOGG" "OFF"
S1 = "Enter the transcript file name:"
GOSUB Ask_File ; Get script file name
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
S0 = "LOG OPEN `""*S0&"`""
SET FLAG(2) ON ; Flag fact for exit
ELSE
IF NOT FLAG(2) ; If was on when entered
LOG CLOSE ; Close the log
GOTO Main ; And don't add to output
ENDIF
S0 = "LOG CLOSE"
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine ; Update statusline
GOTO Output ; Set-up the line to add to output
;
; Toggle the log hold function
;
LogHold:
IF STRCMP "_LOGG" "OFF" ; If not logging
GOTO Main
ENDIF
IF STRCMP "_LOGH" "OFF"
S0 = "LOG SUSPEND"
ELSE
S0 = "LOG RESUME"
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine ; Update statusline
GOTO Output ; Set-up the line to add to output
;
; Set comm parms
;
Parms:
S0 = "" ; Default target vars
S1 = "" ; ..
S2 = "" ; ..
S3 = "" ; ..
GOSUB Ask_Parms ; Ask for a number
LJ S0 ; Left justify response
SWITCH S0 ; Switch on response in Get_parms
CASE "_NULL" ; No entry
SOUND 100,100
GOTO Main ; No action
ENDCASE ; .. no action
CASE "1" ; 300,e,7,1
S0 = "SET BAUD 300"
GOTO Even_7_1
ENDCASE
CASE "2" ; 1200,e,7,1
S0 = "SET BAUD 1200"
GOTO Even_7_1
ENDCASE
CASE "3" ; 2400,e,7,1
S0 = "SET BAUD 2400"
GOTO Even_7_1
ENDCASE
CASE "4" ; 4800,e,7,1
S0 = "SET BAUD 4800"
GOTO Even_7_1
ENDCASE
CASE "5" ; 9600,e,7,1
S0 = "SET BAUD 9600"
GOTO Even_7_1
ENDCASE
CASE "6" ; 19.2,e,7,1
S0 = "SET BAUD 19K"
GOTO Even_7_1
ENDCASE
CASE "7" ; 38.4,e,7,1
S0 = "SET BAUD 38K"
GOTO Even_7_1
ENDCASE
CASE "8" ; 57.6,e,7,1
S0 = "SET BAUD 57K"
GOTO Even_7_1
ENDCASE
CASE "9" ; 115K,e,7,1
S0 = "SET BAUD 115K"
GOTO Even_7_1
ENDCASE
CASE "10" ; 300,n,7,1
S0 = "SET BAUD 300"
GOTO None_8_1
ENDCASE
CASE "11" ; 1200,n,7,1
S0 = "SET BAUD 1200"
GOTO None_8_1
ENDCASE
CASE "12" ; 2400,n,7,1
S0 = "SET BAUD 2400"
GOTO None_8_1
ENDCASE
CASE "13" ; 4800,n,7,1
S0 = "SET BAUD 4800"
GOTO None_8_1
ENDCASE
CASE "14" ; 9600,n,7,1
S0 = "SET BAUD 9600"
GOTO None_8_1
ENDCASE
CASE "15" ; 19.2,n,7,1
S0 = "SET BAUD 19K"
GOTO None_8_1
ENDCASE
CASE "16" ; 38.4,n,7,1
S0 = "SET BAUD 38k"
GOTO None_8_1
ENDCASE
CASE "17" ; 57.6,n,7,1
S0 = "SET BAUD 57k"
GOTO None_8_1
ENDCASE
CASE "18" ; 115K,n,7,1
S0 = "SET BAUD 115K"
GOTO None_8_1
ENDCASE
CASE "19" ; Even parity
S0 = "SET PARITY EVEN"
ENDCASE
CASE "20" ; Odd parity
S0 = "SET PARITY ODD"
ENDCASE
CASE "21" ; No parity
S0 = "SET PARITY ODD"
ENDCASE
CASE "22" ; 7 data
S0 = "SET DATA 7"
ENDCASE
CASE "23" ; 8 data
S0 = "SET DATA 8"
ENDCASE
CASE "24" ; 1 stop bits
S0 = "SET STOP 1"
ENDCASE
CASE "25" ; 2 stop bits
S0 = "SET STOP 2"
ENDCASE
CASE "26" ; COM1
S0 = "SET PORT COM1"
ENDCASE
CASE "27" ; COM2
S0 = "SET PORT COM2"
ENDCASE
CASE "28" ; COM3
S0 = "SET PORT COM3"
ENDCASE
CASE "29" ; COM4
S0 = "SET PORT COM4"
ENDCASE
DEFAULT
SOUND 100,100
GOTO Parms ; Repeat request
ENDCASE
ENDSWITCH
GOTO End_Parms
;
; Set EVEN,7,1 in addition to S0 already set
;
Even_7_1:
S1 = "SET PARITY EVEN" ; Set-up alternate vars
S2 = "SET DATA 7"
S3 = "SET STOP 1"
GOTO End_Parms
;
; Set NONE,8,1 too
;
None_8_1:
S1 = "SET PARITY NONE" ; Set-up alternate vars
S2 = "SET DATA 8"
S3 = "SET STOP 1"
;
; Execute the command and write to script
;
End_Parms:
IF NOT NULL S0
PERFORM S0 ; Execute
WRITE S0*"!" ; Write to log file
ENDIF
IF NOT NULL S1
PERFORM S1 ; Execute
WRITE S1*"!" ; Write to log file
ENDIF
IF NOT NULL S2
PERFORM S2 ; Execute
WRITE S2*"!" ; Write to log file
ENDIF
IF NOT NULL S3
PERFORM S3 ; Execute
WRITE S3*"!" ; Write to log file
ENDIF
GOTO Main ; And we're done
;
; ----- Subroutine: Ask for the parameter selection
; S0 returns the selected method # (1-9) or null
;
Ask_Parms:
WOPEN 2 10 16 70 (contrast) ASK_ESC
ATSAY 2 12 (contrast) " Learn Parms "
ATSAY 3 12 (contrast) " 1) 300,E,7,1"
ATSAY 4 12 (contrast) " 2) 1200,E,7,1"
ATSAY 5 12 (contrast) " 3) 2400,E,7,1"
ATSAY 6 12 (contrast) " 4) 4800,E,7,1"
ATSAY 7 12 (contrast) " 5) 9600,E,7,1"
ATSAY 8 12 (contrast) " 6) 19.2,E,7,1"
ATSAY 9 12 (contrast) " 7) 38.4,E,7,1"
ATSAY 10 12 (contrast) " 8) 57.6,E,7,1"
ATSAY 11 12 (contrast) " 9) 115K,E,7,1"
ATSAY 3 28 (contrast) "10) 300,N,7,1"
ATSAY 4 28 (contrast) "11) 1200,N,7,1"
ATSAY 5 28 (contrast) "12) 2400,N,7,1"
ATSAY 6 28 (contrast) "13) 4800,N,7,1"
ATSAY 7 28 (contrast) "14) 9600,N,7,1"
ATSAY 8 28 (contrast) "15) 19.2,N,7,1"
ATSAY 9 28 (contrast) "16) 38.4,N,7,1"
ATSAY 10 28 (contrast) "16) 57.6,N,7,1"
ATSAY 11 28 (contrast) "18) 115K,N,7,1"
ATSAY 3 44 (contrast) "19) Even par."
ATSAY 4 44 (contrast) "20) Odd parity"
ATSAY 5 44 (contrast) "21) No parity"
ATSAY 7 44 (contrast) "22) 7 data bits"
ATSAY 8 44 (contrast) "23) 8 data bits"
ATSAY 10 44 (contrast) "24) 1 stop bit"
ATSAY 11 44 (contrast) "25) 2 stop bits"
ATSAY 3 60 (contrast) "26) COM1"
ATSAY 4 60 (contrast) "27) COM2"
ATSAY 5 60 (contrast) "28) COM3"
ATSAY 6 60 (contrast) "29) COM4"
ATSAY 12 10 (contrast) "├───────────────────────────────────────────────────────────┤"
COMPARMS S0
ATSAY 13,12 (contrast) "Current setting: "*S0
ATSAY 14 10 (contrast) "├───────────────────────────────────────────────────────────┤"
ATSAY 15 12 (contrast) "Enter selection #:"
ATSAY 16 30 (contrast) " Press ESC to cancel "
ATGET 15 31 (contrast) 2 S0 ; Read selection
WCLOSE
RETURN ; And done
;
; Encrypt/decrypt
;
Encrypt:
GOSUB Ask_Encrypt ; Ask for a number
SWITCH S0 ; Switch on response in Get_parms
CASE "_NULL" ; No entry
SOUND 100,100
GOTO Main ; No action
ENDCASE ; .. no action
CASE "1" ; DES encrypt
S2 = "ENCRYPT"
S3 = "DES"
ENDCASE
CASE "2" ; Simple encrypt
S2 = "ENCRYPT"
S3 = "SIMPLE"
ENDCASE
CASE "3" ; Descrypt
S2 = "DECRYPT"
S3 = "" ; No operand
ENDCASE
DEFAULT
SOUND 100,100
GOTO Encrypt ; Repeat request
ENDCASE
ENDSWITCH
;
; Ask for the source file
;
EncrSrc:
S1 = "Enter the file to be encrypted/decrypted:"
GOSUB Ask_File
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
IF NOT ISFILE S0 ; IF file doesn't exist
S0 = "File does not exist: "*S0
GOSUB Error
GOTO EncrSrc
ENDIF
S4 = S0 ; Save fname
;
; Ask for the destination file
;
EncrDest:
S1 = "Name the output of encryption/decryption:"
GOSUB Ask_File
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
IF ISFILE S0 ; IF file doesn't exist
S0 = "File exists: "*S0&". Delete it Y/N?"
GOSUB Ask_YN
IF SUCCESS
DELETE S0
ELSE
GOTO EncrSrc
ENDIF
ENDIF
S5 = S0 ; Save fname
;
; Ask for the password
;
EncrPsw:
S1 = "Enter the password:"
GOSUB Ask_File
IF NOT SUCCESS or NULL S0 ; IF ESC'd out
GOTO Main
ENDIF
S6 = S0 ; Save fname
;
; Execute the command and write to script
;
S0 = S2&" S4 S5 S6 "*S3
PERFORM S0 ; Execute
IF NOT SUCCESS ; If it failed
S0 = "Encrypt/decrypt failed. Nothing logged to script."
GOSUB Error
Goto Main
ENDIF
;
; Log an encrypt/decrypt sequence
;
WRITE "; Encrypt/decrypt!"
WRITE "MESS `"Enter the encrypt/decrypt source: `"!"
WRITE "GET S1 60!"
WRITE "MESS `"Enter the encrypt/decrypt destination: `"!"
WRITE "GET S2 60!"
WRITE "MESS `"Enter the encrypt/decrypt password: `"!"
WRITE "GET S3 60!"
WRITE S2&" S1 S2 S3 "*S3*"!"
GOTO Main ; And we're done
;
; ----- Subroutine: Ask for the parameter selection
; S0 returns the selected method # (1-9) or null
;
Ask_Encrypt:
WOPEN 2 20 8 60 (contrast) ASK_ESC
ATSAY 2 22 (contrast) " Learn D/Encrypt "
ATSAY 3 22 (contrast) " 1) DES encryption: slow "
ATSAY 4 22 (contrast) " 2) Simple encryption: fast"
ATSAY 5 22 (contrast) " 3) Decrypt encrypted file"
ATSAY 6 20 (contrast) "├───────────────────────────────────────┤"
ATSAY 7 22 (contrast) "Enter selection #:"
ATSAY 8 30 (contrast) " Press ESC to cancel "
ATGET 7 41 (contrast) 1 S0 ; Read selection
WCLOSE
RETURN ; And done
;
; Toggle the blank line eater
;
Blnkln:
S0 = "SET BSUPPRESS ON" ; Default as if off
IF STRCMP "_BSUP" "ON " ; Test current setting
S0 = "SET BSUPPRESS OFF" ; Set-up cmd
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine ; Update status line
GOTO Output ; And write to output file
;
; Toggle the CR/CRLF function (on received CRs)
;
CRLF:
S0 = "SET CR CR_LF" ; Default as if off
IF STRCMP "_CRLF" "ON " ; Test current setting
S0 = "SET CR CR" ; Set-up cmd
ENDIF
PERFORM S0 ; Execute instruction in S0
GOSUB StatusLine ; Update status line
GOTO Output ; And write to output file
;
; ----- Subroutine: Draw the basic screen box
;
Screen:
DWINDOW CLEAR ; Clear any window setting
CLEAR (default) ; Clear whole window
SSIZE N99 ; Get current screen size
DWINDOW N99-12,2 N99-12 77 ; Set kbd scrolling region
BOX N99-13, 0,(N99-11),79 (default)
ATSAY 0,0 (default) ">>───────────────────────────────────────────────────────────────────────────<<"
ATSAY 0, 3 (default) " Learn "
ATSAY (N99-13),3 (default) " Keyboard "
ATSAY N99-11, 28 (default) " ESC to terminate "
ATSAY N99-11, 53 (default) " Press F10 for info "
ATSAY N99-10,2 (default) "F1 Load accessory Alt-Q Toggle CR/CRLF Alt-P Set comm parms"
ATSAY N99- 9,2 (default) "F2 Execute script Alt-E Toggle echo Alt-G Toggle blnkln "
ATSAY N99- 8,2 (Default) "F3 Change drive:subdir Alt-C Clear screen PgUp Upload "
ATSAY N99- 7,2 (Default) "F4 Set dft dlo subdir Alt-L Toggle 25/43 PgDn Download "
ATSAY N99- 6,2 (Default) "F5 Toggle line/char Alt-H Hangup Alt-F10 Shell to DOS "
ATSAY N99- 5,2 (Default) "F6 Toggle learn hold Alt-D Dial Alt-0/9 Send macro "
ATSAY N99- 4,2 (Default) "F7 Toggle logging file Alt-N Encrypt/decrypt Ctl-End Send break "
ATSAY N99- 3,2 (Default) "F9 Toggle log hold Alt-Z Toggle masking Ctl-Prt Toggle print "
GOSUB StatusLine
;
; Set cursor positions, and we're done
;
N95 = 1 ; Receive area row
N96 = 0 ; Receive area col
N93 = N99-12 ; Kbd area row
N94 = 2 ; Kbd area col
RETURN
;
; -----Subroutine: Update the status line
;
StatusLine:
IF STRCMP "_DUPL" "HALF"
ATSAY N99-2,2 (default) "Echo"
ELSE
ATSAY N99-2,2 (default) " "
ENDIF
IF STRCMP "_MASK" "ON"
ATSAY N99-2,8 (default) "Mask"
ELSE
ATSAY N99-2,8 (default) " "
ENDIF
IF STRCMP "_BSUP" "ON "
ATSAY N99-2,14 (default) "NoBln"
ELSE
ATSAY N99-2,14 (default) " "
ENDIF
IF STRCMP "_CRLF" "ON "
ATSAY N99-2,21 (default) "CR_LF"
ELSE
ATSAY N99-2,21 (default) " "
ENDIF
IF STRCMP "_LOGG" "ON "
ATSAY N99-2,28 (default) "Logging"
IF STRCMP "_LOGH" "ON"
ATSAY N99-2,37 (default) "Log held"
ELSE
ATSAY N99-2,37 (default) " "
ENDIF
ELSE
ATSAY N99-2,28 (default) " "
ATSAY N99-2,37 (default) " "
ENDIF
IF FLAG(1)
ATSAY N99-2,47 (default) "Print"
ELSE
ATSAY N99-2,47 (default) " "
ENDIF
IF FLAG(9)
ATSAY N99-2,60 (default) "CharMode"
ELSE
ATSAY N99-2,60 (default) "LineMode"
ENDIF
IF FLAG(8)
ATSAY N99-2,70 (default) "LearnHeld"
ELSE
ATSAY N99-2,70 (default) " "
ENDIF
RETURN ; And we're done
;
; ----- Subroutine: Help
;
Help:
WOPEN 0, 0,23,79 (default) HELPESC
ATSAY 0, 2 (Default) " Learn Help "
ATSAY 23,28 (Default) " Press any key to continue "
;
; Help message
;
ATSAY 1,2 (default) " The LEARN script creates a script based upon the actions taken. The"
ATSAY 2,2 (default) "function keys that LEARN will recognize and act upon are listed on the main"
ATSAY 3,2 (default) "screen. Each function results in an addition to the script being created,"
ATSAY 4,2 (default) "with the exception of Alt-F10 (which allows editing of the script while it"
ATSAY 5,2 (default) "is being created... it does not add a SHELL command to the script)."
ATSAY 6,2 (default) ""
ATSAY 7,2 (default) " Initially LEARN is in 'line mode'. When characters (a-z, 1-9) are typed,"
ATSAY 8,2 (default) "they echo in the keyboard box. When RETURN is typed, the whole line is"
ATSAY 9,2 (default) "transmitted, and the appropriate script line(s) are written. The 'mode' may"
ATSAY 10,2 (default) "be switched to 'character', where each keystroke is transmitted when it is"
ATSAY 11,2 (default) "typed (and each keystroke generates a WAITFOR/TRANSMIT command)."
ATSAY 12,2 (default) ""
ATSAY 13,2 (default) "NOTE: The display doubles carets and exclamation points. This is done to"
ATSAY 14,2 (default) "allow the the keystroke to correctly transmitted. Don't be surprised!!"
ATSAY 15,2 (default) ""
ATSAY 16,2 (default) " The LEARN script may be put on HOLD with the F6 key. When held, what"
ATSAY 17,2 (default) "is typed is sent, no script is generated, and no functions are available."
ATSAY 18,2 (default) ""
ATSAY 19,2 (default) " LEARN does not provide all the functionality of COM-AND. The basic"
ATSAY 20,2 (default) "set of functions required to go on-line are provided. Additional settings"
ATSAY 21,2 (default) "may be added to the output script. Extensive editing of the output script"
ATSAY 22,2 (default) "is recommended in any case."
;
; Wait for a keypress, and return
;
KEYGET S0
WCLOSE
RETURN
;
; ESCAPE during this screen
;
HELPESC:
RETURN
;
; ----- Subroutine: Fatal error. Open a window, and display a message
; S0 passes the error message(s)
;
Error:
WOPEN 10,10,12,70 (contrast) Err_Esc
ATSAY 10,12 (contrast) " Learn Error "
ATSAY 11,12 (contrast) S0(0:55); Max msg width 55 chars
ATSAY 12,26 (contrast) " Press any key to continue "
;
; Wait a keypress
;
KEYGET S0 ; Wait for any key
WCLOSE
RETURN
;
; Escape during this screen
;
Err_Esc:
RETURN
;
; ----- Subroutine: Ask for a script file name
; S1 passes the prompt used
; SUCCESS returns fact script file successfully opened
; S0 returns the fname
;
Ask_File:
WOPEN 10 10 13 70 (contrast) ASK_ESC
ATSAY 10 12 (contrast) " Learn Fname "
ATSAY 11 12 (contrast) S1(0:56)
ATSAY 13 30 (contrast) " Press ESC to cancel "
ATGET 12 12 (contrast) 54 S0; Read new fname
WCLOSE
;
; Attempt to execute the entry
;
LJ S0 ; Left justify
S0 = S0 &"" ; Trim spaces
UPPER S0 ; Make pretty
IF NOT NULL S0 ; If nothing entered
SET SUCCESS ON
ELSE
SET SUCCESS OFF
ENDIF
RETURN ; And done
;
; ----- Escape during a subwindow
; .. S0 is returned null
;
Ask_Esc:
S0 = "" ; Make a null return
RETURN
;
; ----- Subroutine: Ask a question and take a y/n answer
; S0 passes the text to be displayed
; SUCCESS returns fact of y/n
;
Ask_YN:
WOPEN 10 10 13 70 (contrast) ASK_ESC
ATSAY 10 12 (contrast) " Learn Y/N "
ATSAY 11 12 (contrast) S0(0:55)
ATSAY 13 30 (contrast) " Press ESC to cancel "
ATGET 12 12 (contrast) 1 S0 ; Read y/n
WCLOSE
;
; Interperet the response
;
IF NULL S0 or FIND S0 "Y" ; If c/r yes
SET SUCCESS ON
ELSE
SET SUCCESS OFF
ENDIF
RETURN ; And done
;
; ----- Subroutine: Write a line (in S0) to the output file
;
WriteLn:
WRITE S0 ; Write to file
WRITE "!" 1 ; Add a crlf
RETURN ; And continue
;
; ----- Subroutine: Write initial settings out to the output file
;
Initial:
;
; Comments
;
IF CONNECTED
S0 = "; -------------------------------------------------------"
GOSUB WriteLn
S0 = "; WARNING: This script learned after connection was made " *"_Date"
GOSUB WriteLn
S0 = "; ------------------------------------------------------- "
GOSUB WriteLn
GOTO No_Init
ENDIF
;
; Save initial settings
;
S0 = "; Initial state: "*"_Date"
GOSUB WriteLn
S0 = "SET DUPLEX "*"_DUPL"
GOSUB WriteLn
S0 = "EMULATE "*"_EMUL"
GOSUB WriteLn
S0 = "SET 25"
IF GT "_SSIZ" 25
S0 = "SET 43"
ENDIF
GOSUB WriteLn
S0 = "SET MASK "*"_MASK"
GOSUB WriteLn
S0 = "SET CR CR_LF"
IF STRCMP "_CRLF" "OFF"
S0 = "SET CR CR"
ENDIF
GOSUB WriteLn
;
; Save current comm parameters
;
COMPARM S1
S0 = "SET PORT "*S1(11:14)
GOSUB WriteLn
S0 = "SET BAUD "*S1(0:3)
GOSUB WriteLn
IF STRCMP S1(5:5) "E"
S0 = "SET PARITY EVEN"
ELSE
IF STRCMP S1(5:5) "O"
S0 = "SET PARITY ODD"
ELSE
S0 = "SET PARITY NONE"
ENDIF
ENDIF
GOSUB WriteLn
S0 = "SET DATA "*S1(7:7)
GOSUB WriteLn
S0 = "SET STOP "*S1(9:9)
GOSUB WriteLn
;
; Final comment to start learned portion
; .. and a few settings that might be desired on/off line
;
No_Init:
S0 = "; Learned script"
GOSUB WriteLn
S0 = "LEGEND `"Script learned: `"*`""*"_Date"*"`""
GOSUB WriteLn
IF FLAG(1)
S0 = "PRINTER ON"
ELSE
S0 = "PRINTER OFF"
ENDIF
GOSUB WriteLn
S0 = "SET CHAT "*"_CHAT"
GOSUB WriteLn
S0 = "SET KBDB "*"_KBDB"
GOSUB WriteLn
RETURN