home *** CD-ROM | disk | FTP | other *** search
- /*
- Crosstalk for Windows "Learn to Login"
-
- Copyright (C) 1989,1990 Digital Communications Associates, Inc.
- All Rights Reserved.
-
- Version 1.00 07-06-89 PJL
- Version 1.01 12-03-89 PJL
- Version 1.1 04-09-90 PJL
- */
-
-
- -- Global variables:
- string net_name, user_name, pword
- string xws_name, xwp_name, ans
- string inchar, outchars, in_str, outstr
- string outfile, scr_file, main_msg, user_key
- integer not_ready, fsize
-
- main_msg = " Use Shift F1-F5 to send, Shift F6 to quit"
- scr_file = "learn.scr"
-
- cr = chr(13)
- lf = chr(10)
- qt = chr(34)
- qt1 = chr(39)
-
-
- -- Are we online yet?
- not_ready = not Online
- while not_ready
- gosub NOT_ONLINE
- wend
-
-
- -- Use entry name as script name if it's there.
- if length(Name) then {
- xwp_name = Name
- save Name
- xws_name = Name
- outfile = Name + ".xws"
- }
- else {
- xwp_name = ""
- gosub GET_FNAME
- }
- xws_name = upcase(xws_name)
-
- label CHECK_FNAME
- if instr(outfile,"\") <> 0 then {
- i = 1
- while i < 4
- if mid(outfile,i,1) = "\" then i = 5
- else i = i + 1
- wend
- } else i = 5
- if i = 5 then outfile = DirXws + "\" + outfile
-
- outfile = upcase(outfile)
- while exists(outfile)
- Radio1 = 1 : Radio2 = 0
- DialogBox 45, 30, 228, 94
- LText 6, 6, 216, 8, "A script named "+xws_name+".XWS already exists."
- LText 6, 22, 64, 8, "Do you wish to:"
- RadioButton 20, 40, 122, 10, "Create a new "+xws_name+" script", Radio1, TABSTOP GROUP
- RadioButton 20, 54, 130, 10, "Choose a different script name", Radio2
- DefPushButton 53, 74, 36, 14, "Ok", TABSTOP GROUP
- PushButton 139, 74, 36, 14, "Cancel", CANCEL TABSTOP
- EndDialog
- if choice = 2 then end
- if Radio1 then delete outfile
- else gosub GET_FNAME : goto CHECK_FNAME
- wend
-
-
- -- Open the script file.
- f = freefile
- open output outfile as #f
- write #f, '/*'
- write #f, ' Login Script ';
- if length(xwp_name) then ...
- write #f, 'for '+upcase(Name)+".XWP"
- else write #f, xws_name
- write #f, ' Created '+date+' by LEARN.XWS'
- write #f, '*/'
- write #f, ''
- close #f
- fsize = filesize(outfile)
-
-
- -- Go online?
- if not Online then {
- Script = ''
- trap on
- if Local = On then go
- else dial Number
- e = error
- if not Online then {
- alert "Unable to establish connection - try again later.", OK
- end
- }
- trap off
- }
-
-
- -- Program function keys with LEARN options.
- kclear
- if Newline then estr = "ENTER (`^M`^J)"
- else estr = "ENTER (`^M)"
- fkey 1, " ", "NETID"
- fkey 2, " ", "USERID"
- fkey 3, " ", "PASSWORD"
- fkey 4, " ", estr
- fkey 5, " ", "a string"
- fkey 6, " ", "End Learn"
- ShowActive = On
- ShowKeyBar = On
- Message main_msg
-
-
- -- Setup login value variables.
- net_name = NetID
- user_name = UserID
- pword = Password
-
-
- -- Loop on user's keystrokes.
- user_key = 0
- while Online
- gosub CHECK_PORT
- user_key = inkey
- if user_key <> 0 then gosub CHECK_KEY
- wend
- end
-
-
- label CHECK_KEY
- if user_key = 1041 then gosub SEND_NETID
- else if user_key = 1042 then gosub SEND_USERID
- else if user_key = 1043 then gosub SEND_PASSWORD
- else if user_key = 1044 then gosub SEND_ENTER
- else if user_key = 1045 then gosub SEND_STRING
- else if user_key = 1046 then goto SAVE_AND_QUIT
- else if user_key = 13 then gosub USER_KEYSTROKE
- else if user_key = 8 or user_key = 127 then {
- i = length(outchars)
- if i > 0 then outchars = left(outchars,i-1)
- reply chr(user_key);
- }
- else {
- if length(outchars) >= 80 then ...
- gosub USER_KEYSTROKE
- outchars = outchars + chr(user_key)
- reply chr(user_key);
- }
- return
-
-
- label CHECK_PORT
- inchar = bitstrip(nextchar)
- if not null(inchar) then {
- print inchar;
- in_str = right(in_str,40) + inchar
- }
- return
-
-
- -- Send NetID value and add "reply NetID" command to script.
- LABEL SEND_NETID
- gosub WAIT_FOR_LINE
- if null(net_name) then {
- cur_msg = " Please type in your NetID."
- gosub INPUT_STRING
- net_name = user_string
- }
- outstr = net_name
- gosub SEND_REPLY
- code_line = "reply NetID"
- gosub ADD_LINE
- return
-
-
- -- Send UserID value and add "reply UserID" command to script.
- LABEL SEND_USERID
- gosub WAIT_FOR_LINE
- if null(user_name) then {
- cur_msg = " Please type in your UserID."
- gosub INPUT_STRING
- user_name = user_string
- }
- outstr = user_name
- gosub SEND_REPLY
- code_line = "reply UserID"
- gosub ADD_LINE
- return
-
-
- -- Send Password value and add "reply Password" command to script.
- LABEL SEND_PASSWORD
- gosub WAIT_FOR_LINE
- if null(pword) then {
- cur_msg = " Please type in your Password."
- gosub INPUT_STRING
- pword = user_string
- }
- outstr = pword
- gosub SEND_REPLY
- code_line = "reply Password"
- gosub ADD_LINE
- return
-
-
- -- Send a carriage return to the host.
- LABEL SEND_ENTER
- gosub WAIT_FOR_LINE
- if length(code_line) and outstr <> in_str then gosub ADD_LINE
- reply
- wait 2 ticks
- code_line = "reply"
- gosub ADD_LINE
- return
-
-
- -- Ask the user to enter a string, and send the string to the host.
- LABEL SEND_STRING
- gosub WAIT_FOR_LINE
- cur_msg = " Enter the string to send."
- gosub INPUT_STRING
- outstr = destore(user_string)
- gosub SEND_REPLY
- code_line = "reply " + qt + user_string + qt
- gosub ADD_LINE
- return
-
-
- -- Send user's typed keystrokes to the host.
- LABEL USER_KEYSTROKE
- gosub WAIT_FOR_LINE
- gosub ADD_LINE
- reply
- if null(outchars) then code_line = "reply"
- else if upcase(outchars) = upcase(net_name) then ...
- code_line = "reply NetID"
- else if upcase(outchars) = upcase(user_name) then ...
- code_line = "reply UserID"
- else if upcase(outchars) = upcase(pword) then ...
- code_line = "reply Password"
- else code_line = "reply " + qt + outchars + qt
- gosub ADD_LINE
- outchars = ""
- return
-
-
- -- Build WAIT command using last line of text from host.
- -- Strip leading/trailing whitespace and limit to 20 chars.
- -- ENSTORE control chars so they're easier to read.
- LABEL WAIT_FOR_LINE
- code_line = ""
- in_str = strip(in_str, 1, 3)
- if null(in_str) then return
-
- i = instr(in_str, cr)
- while i
- in_str = mid(in_str, i + 1)
- i = instr(in_str, cr)
- wend
- i = instr(in_str, lf)
- while i
- in_str = mid(in_str, i + 1)
- i = instr(in_str, lf)
- wend
-
- if right(in_str) = right(outchars) then ...
- in_str = left(in_str,length(in_str)-length(outchars))
- if null(in_str) then return
-
- if instr(in_str, qt) then ...
- code_line = "wait for " + qt1 + enstore(in_str) + qt1
- else code_line = "wait for " + qt + enstore(in_str) + qt
-
- return
-
-
- -- Send a reply to host.
- LABEL SEND_REPLY
- reply outstr
- if in_str = outstr then in_str = "" : return
-
-
- -- Add a line to the new script.
- LABEL ADD_LINE
- f = freefile
- open append outfile as #f
- if length(code_line) then {
- write line #f, code_line
- if left(code_line,5) = "reply" then write line #f, ""
- }
- close #f
- in_str = ""
- return
-
-
- -- Input a string.
- LABEL INPUT_STRING
- user_string = ""
- alert cur_msg, OK, CANCEL, user_string
- if choice = 2 then pop
- return
-
-
- -- Put up an alert box.
- LABEL ALERT_DIALOG
- ans = ""
- while null(ans)
- alert alert_msg, OK, CANCEL, ans
- if choice = 2 then end
- wend
- return
-
-
- -- Get a phone book entry for the call.
- LABEL NOT_ONLINE
- if length(Name) then {
- t1 = "Place a call to " + Name + "."
- t2 = "Call a different phone book entry."
- }
- else {
- t1 = "Dial a number using the current setup."
- t2 = "Call an existing phone book entry."
- }
- tl1 = length(t1)*4 + 10
- tl2 = length(t2)*4 + 10
- Radio1 = 1 : Radio2 = 0 : Radio3 = 0
- DialogBox 45, 30, 228, 108
- LText 6, 6, 216, 8, "You must be connected to a host computer to use LEARN."
- LText 6, 22, 64, 8, "Do you wish to:"
- RadioButton 20, 40, tl1, 10, t1, Radio1, TABSTOP GROUP
- RadioButton 20, 54, tl2, 10, t2, Radio2
- RadioButton 20, 68, 162, 10, "Create a new phone book entry to call.", Radio3
- DefPushButton 53, 88, 36, 14, "Ok", TABSTOP GROUP
- PushButton 139, 88, 36, 14, "Cancel", CANCEL TABSTOP
- EndDialog
- if choice = 2 then end
- if Radio1 then goto CHECK_NUMBER
- if Radio2 then goto WHICH_ENTRY
-
-
- -- User wants to create a new entry.
- LABEL CHAIN_NEWCALL
- DialogBox 55, 30, 208, 70
- LText 6, 6, 196, 8, "Control will now be passed to the NEWCALL script."
- LText 6, 18, 192, 8, "Re-run Learn when you are finished creating your"
- LText 6, 30, 84, 8, "new phone book entry."
- DefPushButton 52, 50, 36, 14, "Ok", TABSTOP
- PushButton 120, 50, 36, 14, "Cancel", TABSTOP
- EndDialog
- if choice = 2 then end
- chain "NEWCALL"
-
-
- -- User wants to call a different entry.
- LABEL WHICH_ENTRY
- alert_msg = "Please enter a phone book entry name:"
- gosub ALERT_DIALOG
- if inbook(ans) then load ans
- else {
- alert "Error: No such entry.", OK
- return
- }
-
-
- -- Get number to dial if we need one.
- LABEL CHECK_NUMBER
- if null(Number) and Local = Off then {
- alert_msg = "Please enter a phone number:"
- gosub ALERT_DIALOG
- Number = ans
- }
- not_ready = false
- return
-
-
- -- Get a name for the script.
- label GET_FNAME
- alert_msg = "Please enter a script name, 1 to 8 letters in length:"
- gosub ALERT_DIALOG
- if length(ans) > 8 then ans = left(ans,8)
- i = instr(ans,".")
- if i = 0 then {
- outfile = ans + ".xws"
- xws_name = ans
- }
- else {
- outfile = ans
- xws_name = mid(outfile,i-1)
- }
- xws_name = upcase(xws_name)
- return
-
-
- -- Save phone book entry?
- LABEL SAVE_AND_QUIT
- if filesize(outfile) <= fsize then {
- delete outfile
- end
- }
-
- -- save screen contents first
- row = ypos
- col = xpos
- f = freefile
- open output scr_file as #f
- i = 1
- while i <= 24
- write line #f, winstring(i,1,Columns)
- i = i + 1
- wend
- close #f
-
- if not null(xwp_name) then load xwp_name
- else new
- NetID = net_name
- UserID = user_name
- Password = pword
-
- s1 = "Do you wish your " + xws_name + " script to disconnect,"
- s2 = "or leave you online, when the script ends?"
- Check1 = Off
- DialogBox 52, 20, 216, 58
- LText 6, 6, 188, 8, s1
- Ltext 6, 18, 208, 8, s2
- CheckBox 19, 38, 118, 14, "Disconnect at end of script", Check1, TABSTOP
- DefPushButton 168, 38, 32, 14, "Ok", OK TABSTOP
- EndDialog
- if Check1 then {
- code_line = "bye"
- gosub ADD_LINE
- alert "Do you wish to disconnect now?", "Yes", "No"
- if choice = 1 then bye
- code_line = "end"
- gosub ADD_LINE
- }
-
- s1 = "Do you wish to make " + xws_name + ".XWS the Login script"
- s2 = "this phone book entry?"
- DialogBox 52, 20, 218, 58
- LText 6, 8, 212, 8, s1
- LText 6, 20, 88, 8, s2
- DefPushButton 134, 38, 32, 14, 'Yes', OK TABSTOP
- PushButton 176, 38, 32, 14, 'No', CANCEL TABSTOP
- EndDialog
- if choice = 1 then Script = xws_name
- else Script = ''
-
- if not null(xwp_name) then save xwp_name
- else {
- s1 = "Please enter a phone book name if you wish"
- s2 = "LEARN to save this phone book entry."
- if inbook(xws_name) then xws_name = ''
- DialogBox 52, 20, 214, 78
- LText 6, 6, 168, 8, s1
- LText 6, 18, 144, 8, s2
- LText 6, 40, 56, 8, "Save entry as:"
- EditText 66, 38, 36, 12, xws_name, in_str, TABSTOP
- DefPushButton 134, 58, 32, 14, 'Ok', OK TABSTOP
- PushButton 176, 58, 32, 14, 'Cancel', CANCEL TABSTOP
- EndDialog
- if choice = 1 and length(in_str) then save in_str
- }
-
- -- restore screen contents
- if exists(scr_file) then {
- f = freefile
- open input scr_file as #f
- in_str = ''
- blank_str = pad('',Columns,' ',2)
- i = 1
- while i <= 24
- read line #f, in_str
- if in_str <> blank_str then ...
- ? at i,1, in_str;
- i = i + 1
- wend
- ? at row,col, '';
- close #f
- delete scr_file
- }
-
- end
-