; ----- COM-AND Multi-dialer script ; ; This script opens a window and asks for up to 10 dialing directory ; numbers (with or without long distance prefix). As numbers are ; selected, the dialing directory values are displayed (and the dialing ; directory may be cycled through, searching). ; ; When dialing is initiated, the current selections are saved to a file ; on the current drive/subdirectory named DIALER.DAT. If a connection ; is made, the DIALER.DAT is updated to eliminate the connection just ; made from the list. ; ; If a script is associated with the dialing directory entry to which ; connection is made, it is EXECUTED just as if from Alt-D. ; ; R.McG, commenced 10/88 ; updated 3/89 (CLOG start and hit, and add alarm) ; ----- Usages ----------------- ; S19 -----> Parameter string read/written to the .DAT file ; N8 ------> Saved cursor row # ; N9 ------> Saved cursor col # ; N10-N19 -> Working storage for the screen display (LD# and DD#) ; ------------------------------ ; Initialization ; ;* TRACE ON CLEAR CURSOR N8,N9 ; Save cursor on entry ON ESCAPE GOSUB Exit ; SAVE is performed in Window LEGEND " Multi-dialer pop-up" SET TTHRU OFF ; Disallow typeahead CLOG "* Dialer multi-dialer invoked" ; ; Paint an initial window, using saved values ; GOSUB Window ; Open the window GOSUB Get_Last ; Get last Parm string GOSUB Parse_Parm ; Parse_Parms GOSUB All_Fields ; Display all fields LOCATE 7,8 ; Set cursor to 1st entry ; ; Main-loop - look for keyentry ; Main_Loop: SET TTHRU OFF ; Disallow typeahead KEYGET S0 ; Get a keystroke ; ; Act upon the keystroke ; Have_Key: SWITCH S0 CASE "4900" ; Pgup GOTO PgUp ENDCASE CASE "5100" ; PgDn GOTO PgDn ENDCASE CASE "4700" ; Home GOTO Home ENDCASE CASE "4F00" ; End GOTO End ENDCASE CASE "0D" ; C/r GOTO Perform ENDCASE CASE "4800" ; Cursor up GOTO UpLine ENDCASE CASE "5000" ; Cursor down GOTO DnLine ENDCASE CASE "4B00" ; Cursor Left GOTO Left ENDCASE CASE "4D00" ; Cursor right GOTO Right ENDCASE CASE "09" ; Tab GOTO Right ENDCASE CASE "0F00" ; Shift-tab GOTO Left ENDCASE ENDSWITCH ; ; Any other keystrokes must be ASCII keys ; IF NOT NULL S0(1:3) SOUND 100,100 GOTO Main_Loop ENDIF ; ; Decide where we are by the current cursor, and begin field entry ; CURSOR N0,N1 IF GE N1 11 GOSUB Enter_DD ; Enter dialing directory # GOTO Have_Key ; Return with a new keystroke ELSE GOSUB Enter_LD ; Enter Long distance # GOTO Right ; Move to next field ENDIF ; ; ----- Page up (cycle backwards through possible values) ; PgUp: CURSOR N1,N2 IF GE N2 11 N0 = N10[N1-7] N3 = N0/1000 ; Cycle DD# N0 = N0-(N0/1000)*1000 N0 = N0-1 IF LT N0 0 N0 = 100 ENDIF N0 = N0+N3*1000 ELSE N0 = N10[N1-7] N3 = N0-(N0/1000)*1000 ; Cycle LD# N0 = N0/1000 N0 = N0-1 IF LT N0 0 N0 = 4 ENDIF N0 = N3+N0*1000 ENDIF ; ; Restore the value (N0, index N1) and display ; N10[N1-7] = N0 GOSUB One_Field GOTO Main_Loop ; ; ----- Page down (cycle forwards through possible values) ; PgDn: CURSOR N1,N2 IF GE N2 11 N0 = N10[N1-7] N3 = N0/1000 ; Cycle DD# N0 = N0-(N0/1000)*1000 N0 = N0+1 IF GT N0 100 N0 = 0 ENDIF N0 = N0+N3*1000 N10[N1-7] = N0 GOSUB One_Field ELSE N0 = N10[N1-7] N3 = N0-(N0/1000)*1000 ; Cycle LD# N0 = N0/1000 N0 = N0+1 IF GT N0 4 N0 = 0 ENDIF N0 = N3+N0*1000 ENDIF ; ; Restore the value (N0, index N1) and display ; N10[N1-7] = N0 GOSUB One_Field GOTO Main_Loop ; ; ----- Up a line ; UpLine: CURSOR N0,N1 N0 = N0-1 IF LT N0 7 N0 = 16 ENDIF IF GE N1 11 N1 = 11 ; Set new start-of-field ELSE N1 = 8 ; Set new start-of-field ENDIF LOCATE N0,N1 GOTO Main_Loop ; ; ----- Down a line ; DnLine: CURSOR N0,N1 N0 = N0+1 IF GT N0 16 N0 = 7 ENDIF IF GE N1 11 N1 = 11 ; Set new start-of-field ELSE N1 = 8 ; Set new start-of-field ENDIF LOCATE N0,N1 GOTO Main_Loop ; ; ----- Home (move to first line) ; Home: LOCATE 7,8 GOTO Main_Loop ; ; ----- End (Move to last line) ; End: LOCATE 11,8 GOTO Main_Loop ; ; ----- Left (Next field) ; Left: CURSOR N0,N1 IF GE N1 11 N1 = 8 ; Move to previous field ELSE N0 = N0-1 ; Move to previous line N1 = 11 ENDIF IF LT N0 7 ; Last field N0 = 16 ; Wrap ENDIF LOCATE N0,N1 ; And reposition cursor GOTO Main_Loop ; ; ----- Right (Previous field) ; Right: CURSOR N0,N1 IF GE N1 11 N0 = N0+1 ; Move to next row N1 = 8 ELSE N1 = 11 ; Move to next field ENDIF IF GT N0 16 ; Last field N0 = 7 ; Wrap ENDIF LOCATE N0,N1 ; And reposition cursor GOTO Main_Loop ; ; ----- Subroutine Exit - terminate the process ; Exit: RESTORE ; Saved screen LOCATE N8,N9 ; Restore cursor EXIT ; ; ----- Subroutine: Enter a dialing directory # ; .. on entry S0 -> The first keystroke ; .. N1 within this subroutine is always current row# ; .. S9 within this subroutine the field being constructed ; .. N6 within this subroutine is an index to field being constructed ; Enter_DD: CURSOR N1,N2 ; Get current row N0 = N10[N1-7] N0 = (N0/1000)*1000 ; Fake a 0 DD# with old LD# GOSUB One_Field ; Clear previous values on screen N6 = 0 ; Index to field being built S9 = "" ; Clear field ; ; Look for an initial space or backspace (this 'blank's the field) ; IF STRCMP S0 " " ; If enter with space N10[N1-7] = N0 GOTO DD_Keypress ; Start w/new key ENDIF IF STRCMP S0 "08" ; If enter with backspace N10[N1-7] = N0 GOTO DD_Keypress ; Start w/new key ENDIF ; ; The space bar terminates data entry ; DD_Test: IF STRCMP S0 " " ; If space key S0 = "4D00" ; Fake a cursor right GOTO DD_Store ; End of routine ENDIF ; ; Look for special chars (tab, and backspace, and non-ASCII) ; SWITCH S0 CASE "09" ; Tab key GOTO DD_Store ENDCASE CASE "0D" ; Carriage rtn end field here S0 = "4D00" ; Fake a cursor right GOTO DD_Store ENDCASE CASE "08" ; Backspace IF GT N6 0 ; If anything entered CURSOR N1,N2 N2 = N2-1 LOCATE N1,N2 ATSAY N1,N2 (default) " " S1(N6:N6) = " " N6 = N6-1 ENDIF GOTO DD_Keypress ; And go for another key ENDCASE ENDSWITCH IF NOT NULL S0(1:3) ; Not ascii key GOTO DD_Store ; End of routine ENDIF ; ; Filter only numeric chars here ; CTOI S0 N0 ; Easier comparison IF LT N0 48 ; 48 = '0' GOTO DD_Invalid ENDIF IF GT N0 57 ; 56 = '9' GOTO DD_Invalid ENDIF ; ; Add the character to our field being constructed ; S9(N6:N6) = S0 ; Add the char N6 = N6+1 ; ; Display the keystroke in S0 ; CURSOR N1,N2 ATSAY N1,N2 (default) S0(0:0) N2 = N2+1 ; Increment cursor LOCATE N1,N2 ; ; Loop for more (unless field is full) ; IF GE N6 3 ; 3 digits entered S0 = "4D00" ; Fake a cursor right GOTO DD_Store ; Can't be more ENDIF GOTO DD_Keypress ; ; Invalid keypress ; DD_Invalid: SOUND 100,100 ; ; Request the next key ; DD_Keypress: KEYGET S0 GOTO DD_Test ; ; Update the remainder of the display too ; DD_Store: IF EQ N6 0 ; Nothing stored GOTO DD_Exit ; Cancel entry ENDIF N3 = S9 ; Save current value IF GT N3 100 ; Set upper bound N3 = 100 ENDIF IF LT N3 1 ; Set lower bound N3 = 1 ENDIF N0 = N10[N1-7] N0 = N3+(N0/1000)*1000 ; Add new DD# and old LD# N10[N1-7] = N0 ; ; Update the display and we're done ; DD_Exit: N0 = N10[N1-7] GOSUB One_Field ; Using N0,N1 RETURN ; ; ----- Subroutine: Enter a long distance # ; .. on entry S0 -> The first keystroke ; Enter_LD: SWITCH S0 CASE "+" N0 = 1 ENDCASE CASE "-" N0 = 2 ENDCASE CASE "#" N0 = 3 ENDCASE CASE "@" N0 = 4 ENDCASE CASE "1" N0 = 1 ENDCASE CASE "2" N0 = 2 ENDCASE CASE "3" N0 = 3 ENDCASE CASE "4" N0 = 4 ENDCASE DEFAULT N0 = 0 S0 = " " SOUND 100,100 ENDCASE ENDSWITCH ; ; Clear the field, and redisplay ; CURSOR N1,N2 ATSAY N1,N2 (Default) S0(0:0) ; ; Update the remainder of the display too ; N3 = N0 ; Save current value N0 = N10[N1-7] N0 = N0-(N0/1000)*1000 ; Extract DD# N0 = N0+N3*1000 ; Add new DD# N10[N1-7] = N0 ; ; Flesh out the display and we're done ; GOSUB One_Field ; Using N0,N1 RETURN ; ; ----- Display a single field ; .. N0 -> The LD code*1000 + the dialing directory # ; N1 -> The display line # ; .. N2,N3,S10,S11 are modified ; One_Field: S10 = " " ATSAY N1,7 (Default) S10(0:67) ; ; Extract the LD code and dialing directory # ; N2 = N0/1000 ; Set LD # N3 = N0-(N0/1000)*1000 ; Set dialing directory # ; ; Set-up the LD code for display ; IF NOT ZERO N2 S10(0:2) = " "*N2 LD S11 N2 S10(8:30) = S11 ENDIF ; ; Set-up the dialing directory # for display ; IF NOT ZERO N3 S10(4:6) = N3 DNUM S11 N3 S10(32:45) = S11 DIRECTORY S11 N3 S10(47:79) = S11 ENDIF ; ; And display the entry ; ATSAY N1,7 (Default) S10(0:67) RETURN ; ; ----- Subroutine: Display all fields ; .. N0,N1,N2,N3,S10,S11 are destroyed ; All_Fields: N0 = N10 N1 = 7 GOSUB One_Field ; Display a single field N0 = N11 N1 = 8 GOSUB One_Field ; Display a single field N0 = N12 N1 = 9 GOSUB One_Field ; Display a single field N0 = N13 N1 = 10 GOSUB One_Field ; Display a single field N0 = N14 N1 = 11 GOSUB One_Field ; Display a single field N0 = N15 N1 = 12 GOSUB One_Field ; Display a single field N0 = N16 N1 = 13 GOSUB One_Field ; Display a single field N0 = N17 N1 = 14 GOSUB One_Field ; Display a single field N0 = N18 N1 = 15 GOSUB One_Field ; Display a single field N0 = N19 N1 = 16 GOSUB One_Field ; Display a single field RETURN ; And we're done ; ; ----- Subroutine: Parse a parameter string in S19 into numeric variables ; .. N10-N19 are returned either set to 0, or a dialing directory # ; S19 -> The saved dialing command ; .. N0,N1 are modifed ; Parse_Parm: FOR N0 = 0,36,4 ; 10x N1 = N0+3 ATOI S19(N0:N1) N1 IF ERROR ; Delimiter N1 = 0 ENDIF N10 = N11 N11 = N12 N12 = N13 N13 = N14 N14 = N15 N15 = N16 N16 = N17 N17 = N18 N18 = N19 N19 = N1 ENDFOR RETURN ; ; ----- Subroutine: Get the last dialing parameter used ; .. S19 returns the parameter ; Get_Last: S19 = "DIALER.DAT" IF ISFILE S19 FOPENI "DIALER.Dat" TEXT ; Name of data file IF FAILURE GOTO No_Get ENDIF ELSE GOTO No_Get ENDIF ; ; Read the firt record in the file ; READ S19 80 N0 IF EOF GOTO No_Get ENDIF FCLOSEI ; Done for now RETURN ; ; No file or record ; No_Get: S19 = " " RETURN ; ; ----- Subroutine: Store current selections for next use ; .. S19 is modified ; Set_Last: S19 = "DIALER.DAT" FOPENO "DIALER.Dat" TEXT ; Name of data file IF FAILURE RETURN ENDIF S19(0:4) = N10 S19(5:9) = N11 S19(10:14) = N12 S19(15:19) = N13 S19(20:24) = N14 S19(25:29) = N15 S19(30:34) = N16 S19(35:39) = N17 S19(40:44) = N18 S19(45:49) = N19 WRITE S19 50 FCLOSEO RETURN ; ; ----- Open a window with blank fields ; Window: SAVE 1,5 23 75 BOX 1,5 23 75 (default) ATSAY 1,7 (default) " COM-AND Multi-dialer " ATSAY 2,7 (default) "Select up to 10 dialing directory entries (using or not using a long" ATSAY 3,7 (default) "distance prefix). Sequential redial begins when you hit return." ATSAY 4,5 (default) "쳐컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴�" ATSAY 5,7 (default) "LD# DD# (from LD directory) (from dialing directory)" ATSAY 6,7 (default) "--- --- ----------------------- -------------- --------------------" ATSAY 17,5 (default) "쳐컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴�" ATSAY 18,7 (default) "Use cursor up/down to select a line in the display. Use cursor left" ATSAY 19,7 (default) "and right to select a field. PgUp/PgDn cycle possible values." ATSAY 20,7 (default) "LD codes are 0,' ' = none, 1 or +, 2 or -, 3 or #, 4 or @. DD codes" ATSAY 21,7 (default) "are 1-100. Current values are always displayed. Empty entries are" ATSAY 22,7 (default) "ignored. A carriage return begins the dialing sequence." ATSAY 23,30 (default) " Press ESC to exit " RETURN ; ; ----- Subroutine: Set for dialing ; .. N2 on entry is the directory # ; Set_Dialing: DPARM S0 N2 ; Get dialing parms ATSAY 21,7 (default) S0 S1 = S0(5:5) SWITCH S1 ; Parity CASE "E" SET PARITY EVEN ENDCASE CASE "O" SET PARITY ODD ENDCASE CASE "N" SET PARITY NONE ENDCASE ENDSWITCH S1 = S0(7:7) SWITCH S1 ; Data bits CASE "7" SET DATA 7 ENDCASE CASE "8" SET DATA 8 ENDCASE ENDSWITCH S1 = S0(9:9) SWITCH S1 ; Stop bits CASE "1" SET STOP 1 ENDCASE CASE "2" SET STOP 2 ENDCASE ENDSWITCH S1 = S0(0:3) SWITCH S1 ; Baud rate CASE " 300" SET BAUD 300 ENDCASE CASE "1200" SET BAUD 1200 ENDCASE CASE "2400" SET BAUD 2400 ENDCASE CASE "4800" SET BAUD 4800 ENDCASE CASE "9600" SET BAUD 9600 ENDCASE ENDSWITCH IF STRCMP S0(11:11) "Y" ; Echo Y/N SET DUPLEX HALF ELSE SET DUPLEX FULL ENDIF RETURN ; ; This exit is taken after we begin to perform the dialing sequence ; Exit_Perform: HANGUP ; HANGUP - may be dialing RESTORE ; Clear 2nd window GOTO Exit ; ; ----- We got a connection ; .. N1 -> The selected entry ; Got_It: RESTORE ; Clear 2nd window RESTORE ; Clear 1st window LOCATE N8,N9 ; Restore cursor SET RDISP ON ; Turn on display ; ; Clear the entry selected here from the saved list ; N0 = 0 ; Set cleared value N10[N1-7] = N0 GOSUB Set_Last ; Save updated list for next time ; ; Log connection ; DIREC S0 N2 ; Get the name SET CLOCK NEW ; Turn on screen clock CLOG "CONNECT (dialer.cmd): "*S0 ; ; If this entry has a script, execute it ; DSCRIPT S0,N2 ; Look for a script IF NOT NULL S0 SET LINKED ON ; Fake from Alt-D EXECUTE S0 ; Chain to new script ENDIF ALARM ; SOund an alarm (if enabled) CONNECT ; Go to terminal mode ; ; ----- We are to perform the redial - is there anything? ; Perform: N6 = 0 FOR N1 = 7,16 N0 = N10[N1-7] N2 = N0-N0/1000*1000 ; DD# IF NOT ZERO N2 ; If there's an entry here GOTO Set_Up ; Start ENDIF ENDFOR ; ; Nothing to do ; SOUND 100,100 GOTO Main_Loop ; And continue ; ; Set-up a new environment ; Set_Up: ;* TRACE ON SET TTHRU ON ; Allow typethrough KFLUSH SET RDISP OFF ; Turn off display ON ESCAPE GOSUB Exit_Perform ; New exit LEGEND " Cycling through selected #'s" ; ; Save the current selection for the next invocation ; GOSUB Set_Last ; Save whole list in case of Escape ; ; Open a window over the last one. ; SAVE 17,5 23 75 BOX 17,5 23 75 (default) ATSAY 17,7 (default) " COM-AND Dialing " ATSAY 23,22 (default) " CR to move to next, ESC to terminate " ; ; Set control values ; N6 = 0 ; Display counter N5 = 35 ; TImeout in seconds ; ; Loop until escape or connect ; .. Note: N1 and N2 must be preserved within the loop ; Loop: FOR N1 = 7,16 ; Loop index (preserve this value!) ; ; Get the current entry's value (0 = not used) ; N0 = N10[N1-7] N2 = N0-N0/1000*1000 ; DD# (preserve this value!) N3 = N0/1000*1000 ; LD# IF NOT ZERO N2 N6 = N6+1 ATSAY 18,7 (default) "Retry #: "*N6*"; Started: "*"_time"*"; Timeout = "*N5*" seconds" ATSAY 19,7 (default) " " ; clear ATSAY 20,7 (default) " " ; clear ATSAY 21,7 (default) " " ; clear ATSAY 22,7 (default) " " ; clear ; ; Using values for this entry get name, number and LD prefix ; DIRECTORY S1 N2 DNUM S2 N2 LD S3 N3 ATSAY 19,7 (default) S1 ATSAY 20,7 (default) S2&S3 ; ; Set parity, data and stop bits, echo, and speed ; GOSUB Set_Dialing ; ; Hangup and send the dialing sequence ; RFLUSH S0 = "_DPREFIX" & S3 & S2 & "_DSUFFIX"&"" ATSAY 22,7 (default) "Hanging up " HANGUP WAITFOR "OK" 5 ; Clear line of modem's "OK" TRANS S0 ATSAY 22,7 (default) "Dialing " ; ; Wait for a non-null response from the modem ; N0 = N5 SET TIMER WHILE GT N0 0 RGET S0 80 N0 ; Wait up to a limit secs IF NOT NULL S0 IF FIND S0 "_MCONNECT"&"" ; Trim trailing blanks GOTO Got_It ELSE ATSAY 22,7 (default) " " ATSAY 22,7 (default) S0 PAUSE 5 N0 = -N5 ; Force end of loop ENDIF ENDIF TSINCE N3,N3,N4 ; Throw away Hrs N0 = N0-N4 ; Compute total time ENDWHILE ENDIF ENDFOR GOTO Loop ; Loops forever - 'til ESC or connect