home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / procomm / pcpdial.arc / VERSA-C.CMD < prev    next >
OS/2 REXX Batch file  |  1988-01-18  |  36KB  |  853 lines

  1. ;;PC Pursuit: VERSAdial, Version 1.3, by Allen Brunson, David Rhoten, and Gizmo
  2. ;;(C) 1988, Allen Brunson
  3.  
  4. ; ===== VARIABLE TABLE =======
  5. ;VERSA is consistent about its use of variables.  Here is a table describing
  6. ;how they are used, including the macros stored in VERSA.KEY.
  7.  
  8. ;S0  PCP level (1 is offline, 2 is local, 3 is remote city)
  9. ;S1  City code
  10. ;S2  BBS phone number
  11. ;S3  Unused in this version
  12. ;S4  Unused in this version
  13. ;S5  Unused in this version
  14. ;S6  Unused in this version
  15. ;S7  Command file to execute upon connection with a BBS
  16. ;S8  RGETs
  17. ;S9  Secondary RGETs, user input, parameter passing from .MNU files
  18.  
  19. ;MACROS IN VERSA.KEY:
  20. ;M7  Local Telenet number <CR>
  21. ;M8  PCP baud rate (format: /##,)
  22. ;M9  User ID <CR>
  23. ;M0  User password <CR>
  24.  
  25. ;Macros M1 through M6 in VERSA.KEY can be set to whatever you wish.
  26.  
  27.  
  28. ; ===== RE_ENTRY =============
  29. ;This section of the command file handles re-entry from the .MNU files, if
  30. ;this has occurred.  If a .MNU file executes VERSA.CMD, it will assign some
  31. ;value to S9.  If S9 is empty, RE_ENTRY will branch to BEGIN, the start of
  32. ;the command file.  If S9 equals "D", "E", or "G", RE_ENTRY will branch to
  33. ;PCPOFF, VERSAOFF, or DISC3 and then CITYCHOICE, respectively.  If a .MNU
  34. ;file has set S9 to "ACTIVE", then dialing will begin at LEVEL1, LEVEL2, or
  35. ;LEVEL3, depending on the current value of S0.  Any other value of S9 is
  36. ;assumed to be an error, so RE_ENTRY displays an error message and goes to
  37. ;VERSAOFF.
  38.  
  39. SWITCH S9            ;Decision based on S9 (information from an .MNU file)
  40.   CASE "_NULL"       ;If S9 not set by .MNU file,
  41.     GOTO BEGIN       ; begin execution normally
  42.   ENDCASE
  43.   CASE "D"           ;If S9 equals "D" (Disconnect),
  44.     GOTO PCPOFF      ; PCPOFF will take care of the disconnection
  45.   ENDCASE
  46.   CASE "E"           ;If S9 equals "E" (Exit),
  47.     CLEAR            ; clear the screen,
  48.     GOTO VERSAOFF    ; and exit
  49.   ENDCASE
  50.   CASE "G"           ;If S9 equals "G" (Go back to city menu),
  51.     FIND S0 "3"      ; look for "3" in S0 (connected to a remote city)
  52.     IF FOUND         ;If found,
  53.       GOSUB DISC3    ; disconnect from remote city
  54.     ENDIF
  55.     GOTO CITYCHOICE  ;Then select a new city
  56.   ENDCASE
  57.   CASE "ACTIVE"      ;If S9 equals "ACTIVE",
  58.     SWITCH S0        ;Decision based on S0 (level information)
  59.       CASE "1"       ;If S0 equals "1" (modem offline),
  60.         GOTO LEVEL1  ; start dialing at LEVEL1
  61.       ENDCASE
  62.       CASE "2"       ;If S0 equals "2" (Local Telenet),
  63.         CLEAR        ; clear screen (LEVEL2 does not do this),
  64.         GOTO LEVEL2  ; and start dialing at LEVEL2
  65.       ENDCASE
  66.       CASE "3"       ;If S0 equals "3" (Remote city),
  67.         CLEAR        ; clear screen (LEVEL3 does not do this),
  68.         GOTO LEVEL3  ; and start dialing at LEVEL3
  69.       ENDCASE
  70.     ENDSWITCH        ;End of decision based on level information
  71.   ENDCASE
  72.   DEFAULT            ;Erroneous information
  73.     CLEAR            ;Clear the screen and
  74.     LOCATE 11,20     ; locate cursor for message
  75.     MESSAGE "Parameter error from menu command file."
  76.     LOCATE 14,0      ; locate cursor for VERSAOFF message
  77.     GOTO VERSAOFF    ; and terminate
  78.   ENDCASE
  79. ENDSWITCH            ;End of decision based on information from a .MNU file
  80.  
  81.  
  82.  
  83. ; ===== BEGIN ================
  84. ;This section of the command file is branched to from RE_ENTRY if VERSA is
  85. ;starting normally.  It sets up some defaults, loads in user information in
  86. ;VERSA.KEY, and always goes to TITLE.
  87.  
  88. BEGIN:
  89. SET CR_IN CR       ;Make sure LFs aren't added to incoming
  90. SET CR_OUT CR      ; or outgoing <CR>s
  91. SET PARITY EVEN    ;Parity and databits must be set to
  92. SET DATABITS 7     ; even and 7 for communicating with Telenet
  93. SET DUPLEX FULL    ;Make sure duplex is FULL
  94. MLOAD "VERSA.KEY"  ;Load in user information
  95. GOTO TITLE         ;Go to beginning of code
  96.  
  97.  
  98.  
  99. ; ===== SUBROUTINES ==========
  100. ;The following routines are called "subroutines," but only two, DISC3 and
  101. ;R/V_MODE, actually end in a RETURN.  They are placed here at the top of the
  102. ;file so that ProComm will find them quickly as it searches for their labels.
  103.  
  104.  
  105. ;CITYREDIAL is branched to from LEVEL2 if the user elects to redial a busy
  106. ;city.  It redials the city, looping continually until it connects, and then
  107. ;goes to PORTSET.
  108.  
  109. CITYREDIAL:
  110. CLEAR                ;Clear screen
  111. TRANSMIT "C D/"      ;Send beginning of city dial command
  112. TRANSMIT S1          ;Send city code
  113. MACRO 8              ;Send PCP baud rate
  114. MACRO 9              ;Send user ID
  115. WAITFOR "="          ;Wait for "PASSWORD ="
  116. MACRO 0              ;Send user password
  117. RGET S8              ;Get first <CR>
  118. RGET S8              ;Get second <CR>
  119. RGET S8              ;Get message
  120. FIND S8 "CONNECTED"  ;Look for "CONNECTED" in S8
  121. IF FOUND             ;If found, city is connected, so
  122.   MESSAGE "^G"       ; beep,
  123.   GOTO PORTSET       ; go to PORTSET
  124. ENDIF
  125. GOTO CITYREDIAL      ;If "CONNECTED" not found, loop and try again
  126.  
  127.  
  128. ;BBSREDIAL is branched to from LEVEL3 if the user elects to redial a busy
  129. ;BBS.  It redials the BBS, looping continually until a connection is made.
  130. ;It then branches to BBSCONNECT.
  131.  
  132. BBSREDIAL:
  133. CLEAR              ;Clear screen -- only done once
  134. LABEL1:            ;Beginning of redial loop
  135. TRANSMIT "A/!"     ;Send Hayes command for "repeat last command"
  136. RGET S8 80 40      ;Wait a maximum of 40 seconds to get first <CR> back
  137. RGET S8            ;Get string from remote modem
  138. FIND S8 "CONNECT"  ;Look for "CONNECT" in modem string
  139. IF FOUND           ;If found, BBS has been connected,
  140.   GOTO BBSCONNECT  ; go to BBSCONNECT
  141. ENDIF
  142. GOTO LABEL1        ;If "CONNECTED" not found, loop and try again
  143.  
  144.  
  145. ;BBSCONNECT is branched to from BBSREDIAL, LEVEL3, NETDIAL, or NETREDIAL
  146. ;whenever a BBS is connected with.  It resets the databits and parity to
  147. ;8 and none, sounds ProComm's alarm, and executes the "linked command file,"
  148. ;if there is one, or exits if there isn't.
  149.  
  150. BBSCONNECT:
  151. SET PARITY NONE          ;Reset parameters
  152. SET DATABITS 8           ; for use with BBSs
  153. ALARM 2                  ;Inform user of connection
  154. MLOAD "PROCOMM.KEY"      ;Reload PROCOMM.KEY
  155. SWITCH S7                ;Decision based on S7 (linked command file)
  156.   CASE "_NULL"           ;If S7 is empty (no linked command file),
  157.     EXIT                 ; then exit
  158.   ENDCASE
  159.   CASE "*"               ;or if S7 is "*" (cleared linked command file),
  160.     EXIT                 ; then exit
  161.   ENDCASE
  162.   DEFAULT                ;Otherwise,
  163.     EXECUTE S7           ; perform the linked command file
  164.   ENDCASE
  165. ENDSWITCH                ;End of decision based on linked command file
  166.  
  167.  
  168. ;PCPOFF can be called from nearly anywhere in the program.  It is executed
  169. ;whenever the user wishes to disconnect from PCP entirely and end VERSA.  It
  170. ;looks at the level information and branches to DISC3, DISC2, and VERSAOFF
  171. ;as needed.
  172.  
  173. PCPOFF:
  174. CLEAR              ;Clear the screen
  175. IF NOT CONNECTED   ;If PCP has disconnected or level is 1 (offline),
  176.   GOTO VERSAOFF    ; go directly to VERSAOFF
  177. ENDIF
  178. SWITCH S0          ;Decision based on S0 (level information)
  179.   CASE "2"         ;If S0 equals "2" (local Telenet level),
  180.     GOTO DISC2     ; disconnect from level 2, VERSAOFF will follow
  181.   ENDCASE
  182.   CASE "3"         ;If S0 equals "3" (Remote city level),
  183.     GOSUB DISC3    ; disconnect from level 3,
  184.     GOTO DISC2     ; disconnect from level 2, VERSAOFF will follow
  185.   ENDCASE
  186. ENDSWITCH          ;End of decision based on level information
  187.  
  188.  
  189. ;DISC3 (DISConnect from level 3) is a true subroutine that is called whenever
  190. ;the user wishes to disconnect from level 3 (connection to a remote city)
  191. ;back to level 2 (connection to local Telenet).  It first makes sure Telenet
  192. ;is still connected before doing anything.  It attempts to get back to the
  193. ;Telenet prompt by issuing a break, but will try a <CR>@<CR> if that doesn't
  194. ;work.  Once at the Telenet prompt, it issues D <CR>, the disconnect command,
  195. ;then RETURNs to caller.
  196.  
  197. DISC3:
  198. CLEAR               ;Clear screen
  199. MESSAGE "Disconnecting from remote city . . ."
  200. IF NOT CONNECTED    ;If Telenet has dropped carrier,
  201.   MESSAGE "^M^JTelenet has disconnected.^M^J"
  202.   ASSIGN S0 "1"     ; level is now 1,
  203.   PAUSE 1           ; allow user to see message,
  204.   RETURN            ; no need to disconnect
  205. ENDIF
  206. BREAK 10            ;Send a break, 10 ms, to return to Telenet prompt
  207. WAITFOR "@" 5       ;Wait for Telenet prompt
  208. TRANSMIT "!"        ;Get fresh prompt, in case of garbage characters
  209. IF NOT WAITFOR      ;If that didn't work,
  210.   TRANSMIT "!@!"    ; transmit <CR>@<CR> to return to Telenet prompt
  211. ENDIF
  212. WAITFOR "@" 5       ;Wait for Telenet prompt
  213. TRANSMIT "D!"       ;Send D<CR> (disconnect from city command)
  214. WAITFOR "@" 5       ;Wait for Telenet prompt
  215. MESSAGE "^M^J^M^J"  ;Send <CR>/<LF>s, in case of DISC2 messages following
  216. PAUSE 1             ;Allow user to see results
  217. ASSIGN S0 "2"       ;Level is now 2 (local Telenet level)
  218. RETURN              ;RETURN to caller
  219.  
  220.  
  221. ;DISC2 (DISConnect from level 2) is called whenever the user wants to
  222. ;disconnect from PCP entirely.  It issues the HANGUP <CR> command and then
  223. ;always "falls through" to VERSAOFF.
  224.  
  225. DISC2:
  226. MESSAGE "Disconnecting from local Telenet . . .^M^J"
  227. TRANSMIT "HANGUP!"  ;Send "HANGUP"<CR> (disconnect from local command)
  228. PAUSE 1             ;Causes "garbage" character to go behind HANGUP
  229. MESSAGE "^M^J"      ;<CR>/<LF> sent to make next message further down
  230.  
  231.  
  232. ;VERSAOFF is always the last routine done (unless a BBS is connected).  It
  233. ;reloads PROCOMM.KEY, since VERSA.KEY was loaded for VERSA use, and then
  234. ;exits.
  235.  
  236. VERSAOFF:
  237. MLOAD "PROCOMM.KEY"        ;Reload PROCOMM.KEY
  238. MESSAGE "VERSA finished."  ;Inform the user of completion
  239. EXIT                       ;End the command file
  240.  
  241.  
  242. ;NETREDIAL is branched to from NETDIAL if the Net Exchange is busy and the
  243. ;user elects to redial.  It redials the Net Exchange using the C PURSUIT
  244. ;command, continually looping until a connection is made.  It then goes to
  245. ;BBSCONNECT.
  246.  
  247. NETREDIAL:
  248. CLEAR                  ;Clear screen
  249. TRANSMIT "C PURSUIT,"  ;Send beginning of Net Exchange dial command
  250. MACRO 9                ;Send user ID
  251. WAITFOR "="            ;Wait for "PASSWORD ="
  252. MACRO 0                ;Send password
  253. RGET S8                ;Get first <CR>
  254. RGET S8                ;Get second <CR>
  255. RGET S8                ;Get message
  256. FIND S8 "CONNECTED"    ;Look for "CONNECTED" in S8
  257. IF FOUND               ;If found,
  258.   GOTO BBSCONNECT      ; go to BBSCONNECT
  259. ENDIF
  260. GOTO NETREDIAL         ;If "CONNECTED" not found, loop and try again
  261.  
  262.  
  263. ;NETDIAL is called from LEVEL2 if it discovers that the current city code is
  264. ;set to NETEX.  NETDIAL calls the Net Exchange using the C PURSUIT command.
  265. ;If the Net Exchange connects, it branches to BBSCONNECT.  If the Net
  266. ;Exchange doesn't connect, NETDIAL asks the user to decide whether or not to
  267. ;redial; it then branches to either NETREDIAL or CITYCHOICE.  Since user
  268. ;input is obtained, "D" and "E" are valid options, meaning NETDIAL might
  269. ;branch to PCPOFF or VERSAOFF, respectively.
  270.  
  271. NETDIAL:
  272. TRANSMIT "C PURSUIT,"  ;Send beginning of Net Exchange dial command
  273. MACRO 9                ;Send user ID
  274. WAITFOR "="            ;Wait for "PASSWORD ="
  275. MACRO 0                ;Send password
  276. RGET S8                ;Get first <CR>
  277. RGET S8                ;Get second <CR>
  278. RGET S8                ;Get message
  279. FIND S8 "CONNECTED"    ;Look for "CONNECTED" in S8
  280. IF FOUND               ;If found,
  281.   GOTO BBSCONNECT      ; go to BBSCONNECT
  282. ENDIF
  283. CLEAR                  ;Otherwise, clear screen
  284. LOCATE 11,16           ;Locate cursor for message
  285. MESSAGE "The Net Exchange is busy.  Begin redial <Y/N>?"
  286. LABEL2:                ;Loop to here in case of erroneous input
  287. LOCATE 11,63           ;Locate cursor for user input
  288. GET S9 1               ;Get user input (1 character)
  289. SWITCH S9              ;Decision based on S9 (user input)
  290.   CASE "Y"             ;If the user enters "Y",
  291.     GOTO NETREDIAL     ; begin redialing
  292.   ENDCASE
  293.   CASE "N"             ;If the user enters "N",
  294.     ASSIGN S7 "*"      ; clear name of Net Exchange linked command file,
  295.     GOTO CITYCHOICE    ; and select another city
  296.   ENDCASE
  297.   CASE "D"             ;If the user enters "D",
  298.     GOTO PCPOFF        ; PCPOFF will take care of the disconnection
  299.   ENDCASE
  300.   CASE "E"             ;If the user enters "E",
  301.     CLEAR              ; clear screen,
  302.     GOTO VERSAOFF      ; exit VERSA
  303.   ENDCASE
  304.   DEFAULT              ;Erroneous input
  305.     LOCATE 11,63       ;Locate cursor,
  306.     MESSAGE "^G "      ; beep and erase erroneous input,
  307.     GOTO LABEL2        ; and redo the GET
  308.   ENDCASE
  309. ENDSWITCH              ;End of decision based on user input
  310.  
  311.  
  312. ;R/V_MODE is a true subroutine that is called from either TITLE or LEVEL3
  313. ;when those routines run into a modem that has been left in Racal/Vadic mode.
  314. ;This routine resets the modem to Hayes mode and then RETURNs.
  315.  
  316. R/V_MODE:
  317. PAUSE 1                ;Wait, in case of INVALID COMMAND response
  318. TRANSMIT "!"           ;Send a <CR>
  319. WAITFOR "*" 2          ;Wait for R/V prompt
  320. IF NOT WAITFOR         ;If R/V prompt doesn't show up,
  321.   GOTO R/V_MODE        ; loop and try again
  322. ENDIF
  323. TRANSMIT "I!"          ;Send "I" command (return to Hayes mode)
  324. WAITFOR "IDLE" 10      ;Wait for confirmation
  325. PAUSE 1                ;Wait for modem to "settle"
  326. TRANSMIT "ATZ!"        ;Reset in Hayes mode
  327. WAITFOR "OK"           ;Wait for "OK"
  328. RETURN                 ;RETURN to caller
  329.  
  330.  
  331.  
  332. ; ===== TITLE ================
  333. ;TITLE is branched to from BEGIN if VERSA is starting normally (no re-entry
  334. ;from a .MNU file).  It draws the title screen and sends an ATZ to determine
  335. ;the current level.  If a modem in Racal/Vadic mode is encountered, it will
  336. ;call R/V_MODE to reset it.  Once the level is discovered, it is stored in S0
  337. ;as a 1, 2, or 3 (for offline, local Telenet level, or remote city level,
  338. ;respectively).  If TITLE can't determine the level, it terminates by calling
  339. ;VERSAOFF.
  340.  
  341. TITLE:
  342. CLEAR                    ;Clear screen
  343. LOCATE 2,0               ;Locate cursor for credit drawing
  344. MESSAGE "                       ╔═══════════════════════════════╗"
  345. MESSAGE "                       ║                               ║"
  346. MESSAGE "                       ║     PC Pursuit: VERSAdial     ║"
  347. MESSAGE "                       ║          Version 1.3          ║"
  348. MESSAGE "                       ║   Written by Allen Brunson,   ║"
  349. MESSAGE "                       ║    David Rhoten, and Gizmo    ║"
  350. MESSAGE "                       ║                               ║"
  351. MESSAGE "                       ║       `"D`" - Disconnect        ║"
  352. MESSAGE "                       ║       `"E`" - Exit VERSA        ║"
  353. MESSAGE "                       ║                               ║"
  354. MESSAGE "                       ╚═══════════════════════════════╝"
  355. LOCATE 15,0              ;Locate cursor for next message
  356. MESSAGE "Determining PC Pursuit level . . .^M^J"
  357. IF NOT CONNECTED         ;If local modem is offline,
  358.   MESSAGE "Modem is currently offline."
  359.   ASSIGN S0 "1"          ; then the level is 1
  360.   PAUSE 1                ;Allow user to see message
  361.   GOTO CITYCHOICE        ;Go to city selection
  362. ENDIF
  363. TRANSMIT "ATZ!"          ;Test for a remote modem
  364. RGET S8 80 3             ;Get first <CR>
  365. RGET S8 80 3             ;This is where "?" will come back, if local Telenet
  366. RGET S9 80 3             ;This is where "OK" will come back, if remote city
  367. FIND S8 "?"              ;Look for "?" in S8
  368. IF FOUND                 ;If "?" is found in S8, we're at local Telenet,
  369.   MESSAGE "^M^J^M^JLocal Telenet level determined."
  370.   ASSIGN S0 "2"          ; therefore, the level is 2
  371.   PAUSE 1                ;Allow user to see message
  372.   GOTO CITYCHOICE        ;Go to city selection
  373. ENDIF
  374. FIND S9 "OK"             ;Look for "OK" in S9
  375. IF FOUND                 ;If "OK" is found in S9, we're at remote level,
  376.   MESSAGE "^M^JRemote city level determined."
  377.   ASSIGN S0 "3"          ; therefore, the level is 3
  378.   PAUSE 1                ;Allow user to see message
  379.   GOTO CITYCHOICE        ;User must enter the current city code
  380. ENDIF
  381. FIND S9 "MANUAL ANSWER"  ;Look for R/V mode response
  382. IF FOUND                 ; If modem is in R/V mode,
  383.   GOSUB R/V_MODE         ; go to R/V mode handling
  384.   MESSAGE "^M^JRemote city level determined."
  385.   ASSIGN S0 "3"          ; Level is determined to be 3
  386.   PAUSE 1                ; Allow user to see message
  387.   GOTO CITYCHOICE        ; User must enter the current city code
  388. ENDIF                    ;If none of that worked,
  389. MESSAGE "^M^JUnable to determine level.^M^J"
  390. GOTO VERSAOFF            ; something is wrong, VERSA will not proceed
  391.  
  392.  
  393.  
  394. ; ===== CITYCHOICE ===========
  395. ;CITYCHOICE is called either when the user must select a city code to dial,
  396. ;in case of level 1 or 2 starts, or when the user must enter the current
  397. ;city code, in the case of level 3 starts.  It displays the city code menu
  398. ;and the current level, then asks for a city code.  If a city code is entered,
  399. ;it goes to MENUBRANCH.  It can also go to PCPOFF if "D" is entered, VERSAOFF
  400. ;if "E" is entered, or to DISC3 if "G" is entered.
  401.  
  402. CITYCHOICE:
  403. CLEAR                         ;Clear screen for menu drawing
  404. MESS"  ╒═════════════════════════╡ PC Pursuit City Menu ╞═════════════════════════╕"
  405. MESS"  │                                                                          │"
  406. MESS"  │  E GAATL *Atlanta       E DCWAS *Washington DC   P CALAN *Los Angeles    │"
  407. MESS"  │  E MABOS *Boston        C ILCHI *Chicago         P CAPAL +Palo Alto      │"
  408. MESS"  │  E OHCLV  Cleveland     C TXDAL *Dallas          P ORPOR  Portland       │"
  409. MESS"  │  E MIDET *Detroit       C TXHOU *Houston         P CARIV +Riverside      │"
  410. MESS"  │  E CTHAR +Hartford      C MOKAN *Kansas City     P CASAC +Sacramento     │"
  411. MESS"  │  E FLMIA  Miami         C WIMIL +Milwaukee       P CASAD +San Diego      │"
  412. MESS"  │  E NETEX  Net Exchange  C MNMIN  Minneapolis     P CASFA *San Francisco  │"
  413. MESS"  │  E NJNEW *Newark        C MOSLO +St. Louis       P CASJO +San Jose       │"
  414. MESS"  │  E NYNYO *New York      M CODEN *Denver          P CASAN +Santa Ana      │"
  415. MESS"  │  E PAPHI *Philadelphia  M AZPHO  Phoenix         P WASEA *Seattle        │"
  416. MESS"  │  E NCRTP  Res Tri Park  M UTSLC  Salt Lake City  * 2400 baud available   │"
  417. MESS"  │  E FLTAM  Tampa         P CAGLE +Glendale        + 300 baud unavailable  │"
  418. MESS"  │                                                                          │"
  419. MESS"  │  Time   E - Eastern                  Options:  <D>isconnect              │"
  420. MESS"  │  Zones  C - Central                            <E>xit                    │"
  421. MESS"  │         M - Mountain                                                     │"
  422. MESS"  │         P - Pacific     Status:                                          │"
  423. MESS"  │                                                                          │"
  424. MESS"  ├──────────────────────────────────────────────────────────────────────────┤"
  425. MESS"  │                                                                          │"
  426. MESS"  ╘══════════════════════════════════════════════════════════════════════════╛"
  427. LOCATE 18,36                  ;Locate for status message
  428. SWITCH S0                     ;Decision based on current level
  429.   CASE "1"                    ;If off line,
  430.     MESSAGE "Off line"        ; put message in menu,
  431.     LOCATE 21,21              ; locate for input message
  432.     MESSAGE "Enter city code of desired city:"
  433.   ENDCASE
  434.   CASE "2"                    ;If local Telenet level,
  435.     MESSAGE "Local Telenet"   ; put message in menu,
  436.     LOCATE 21,21              ; locate for input message
  437.     MESSAGE "Enter city code of desired city:"
  438.   ENDCASE
  439.   CASE "3"                    ;If remote city level,
  440.     MESSAGE "Remote city"     ; put message in menu,
  441.     LOCATE 17,51              ; locate for second message,
  442.     MESSAGE "<G>o to local level"
  443.     LOCATE 21,21              ; locate for input message
  444.     MESSAGE "Enter city code of CURRENT city:"
  445.   ENDCASE
  446. ENDSWITCH
  447. LOCATE 21,54                  ;Locate for user input
  448. GET S9 5                      ;Get user input (5 characters)
  449. SWITCH S9                     ;Decision based on S9 (user input)
  450.   CASE "D"                    ;If the user enters "D",
  451.     GOTO PCPOFF               ; then PCPOFF will take care of disconnection
  452.   ENDCASE
  453.   CASE "E"                    ;If the user enters "E",
  454.     CLEAR                     ; clear screen,
  455.     GOTO VERSAOFF             ; and exit
  456.   ENDCASE
  457.   CASE "G"                    ;If the user enters "G",
  458.     CLEAR                     ; clear the screen
  459.     FIND S0 "3"               ;Look in S0 for "3" (remote city level)
  460.     IF FOUND                  ;If level is 3,
  461.       GOSUB DISC3             ; disconnect from remote city
  462.     ELSE                      ;If at some other level,
  463.       LOCATE 11,19            ; locate, beep, and print message
  464.       MESSAGE "^GNot currently connected to a remote city."
  465.       LOCATE 0,0              ; locate cursor out of the way,
  466.       PAUSE 1                 ; allow user to see message
  467.     ENDIF
  468.     GOTO CITYCHOICE           ;Start over at CITYCHOICE
  469.   ENDCASE
  470.   CASE "_NULL"                ;If the user entered nothing,
  471.     CLEAR                     ; clear screen,
  472.     LOCATE 11,18              ; locate, beep, and print message
  473.     MESSAGE "^GMust enter a city code or displayed option."
  474.     LOCATE 0,0                ; locate cursor out of the way,
  475.     PAUSE 1                   ; allow user to see message,
  476.     GOTO CITYCHOICE           ; and start over at CITYCHOICE
  477.   ENDCASE
  478.   DEFAULT                     ;Anything else is assumed to be a city code,
  479.     ASSIGN S1 S9              ; so assign the input to S1,
  480.     GOTO MENUBRANCH           ; and go to MENUBRANCH
  481.   ENDCASE
  482. ENDSWITCH                     ;End of decision based on user input
  483.  
  484.  
  485.  
  486. ; ===== MENUBRANCH ===========
  487. ;MENUBRANCH is used to determine which .MNU file should be called for a given
  488. ;city code.  It can be called from CITYCHOICE, if the user has just entered
  489. ;a city code, or from LEVEL3 if a user elects not to redial a BBS.  If the
  490. ;user enters an unknown city code, MENUBRANCH notes the fact and asks if the
  491. ;user wants to continue or go back to CITYCHOICE to select another city code.
  492. ;If the user elects to continue, the spare menu in VERSA5.MNU is called.
  493. ;Since user input is obtained, the user might enter "D" or "E", which would
  494. ;cause MENUBRANCH to go to PCPOFF or VERSAOFF, respectively.
  495.  
  496. MENUBRANCH:
  497. SWITCH S1                     ;Decision based on S1 (city code)
  498.   CASE "GAATL"                ;All of the following 34 cases are identical
  499.     ASSIGN S1 "GAATL"         ; (except for the Net Exchange case).  They
  500.     EXECUTE "VERSA1.MNU"      ; simply assure that the string in S1 is all
  501.   ENDCASE                     ; uppercase and then execute the correct .MNU
  502.   CASE "MABOS"                ; file for the selected city.
  503.     ASSIGN S1 "MABOS"
  504.     EXECUTE "VERSA1.MNU"
  505.   ENDCASE
  506.   CASE "OHCLV"
  507.     ASSIGN S1 "OHCLV"
  508.     EXECUTE "VERSA1.MNU"
  509.   ENDCASE
  510.   CASE "MIDET"
  511.     ASSIGN S1 "MIDET"
  512.     EXECUTE "VERSA1.MNU"
  513.   ENDCASE
  514.   CASE "CTHAR"
  515.     ASSIGN S1 "CTHAR"
  516.     EXECUTE "VERSA1.MNU"
  517.   ENDCASE
  518.   CASE "FLMIA"
  519.     ASSIGN S1 "FLMIA"
  520.     EXECUTE "VERSA1.MNU"
  521.   ENDCASE
  522.   CASE "NETEX"                ;If the user wishes to dial the Net Exchange,
  523.     FIND S0 "3"               ; find out if level is 3
  524.     IF FOUND                  ;If it is,
  525.       GOSUB DISC3             ; disconnect from remote city
  526.     ENDIF
  527.     ASSIGN S1 "NETEX"
  528.     EXECUTE "VERSA5.MNU"
  529.   ENDCASE
  530.   CASE "NJNEW"
  531.     ASSIGN S1 "NJNEW"
  532.     EXECUTE "VERSA1.MNU"
  533.   ENDCASE
  534.   CASE "NYNYO"
  535.     ASSIGN S1 "NYNYO"
  536.     EXECUTE "VERSA2.MNU"
  537.   ENDCASE
  538.   CASE "PAPHI"
  539.     ASSIGN S1 "PAPHI"
  540.     EXECUTE "VERSA2.MNU"
  541.   ENDCASE
  542.   CASE "NCRTP"
  543.     ASSIGN S1 "NCRTP"
  544.     EXECUTE "VERSA2.MNU"
  545.   ENDCASE
  546.   CASE "FLTAM"
  547.     ASSIGN S1 "FLTAM"
  548.     EXECUTE "VERSA2.MNU"
  549.   ENDCASE
  550.   CASE "DCWAS"
  551.     ASSIGN S1 "DCWAS"
  552.     EXECUTE "VERSA2.MNU"
  553.   ENDCASE
  554.   CASE "ILCHI"
  555.     ASSIGN S1 "ILCHI"
  556.     EXECUTE "VERSA2.MNU"
  557.   ENDCASE
  558.   CASE "TXDAL"
  559.     ASSIGN S1 "TXDAL"
  560.     EXECUTE "VERSA2.MNU"
  561.   ENDCASE
  562.   CASE "TXHOU"
  563.     ASSIGN S1 "TXHOU"
  564.     EXECUTE "VERSA3.MNU"
  565.   ENDCASE
  566.   CASE "MOKAN"
  567.     ASSIGN S1 "MOKAN"
  568.     EXECUTE "VERSA3.MNU"
  569.   ENDCASE
  570.   CASE "WIMIL"
  571.     ASSIGN S1 "WIMIL"
  572.     EXECUTE "VERSA3.MNU"
  573.   ENDCASE
  574.   CASE "MNMIN"
  575.     ASSIGN S1 "MNMIN"
  576.     EXECUTE "VERSA3.MNU"
  577.   ENDCASE
  578.   CASE "MOSLO"
  579.     ASSIGN S1 "MOSLO"
  580.     EXECUTE "VERSA3.MNU"
  581.   ENDCASE
  582.   CASE "CODEN"
  583.     ASSIGN S1 "CODEN"
  584.     EXECUTE "VERSA3.MNU"
  585.   ENDCASE
  586.   CASE "AZPHO"
  587.     ASSIGN S1 "AZPHO"
  588.     EXECUTE "VERSA3.MNU"
  589.   ENDCASE
  590.   CASE "UTSLC"
  591.     ASSIGN S1 "UTSLC"
  592.     EXECUTE "VERSA4.MNU"
  593.   ENDCASE
  594.   CASE "CAGLE"
  595.     ASSIGN S1 "CAGLE"
  596.     EXECUTE "VERSA4.MNU"
  597.   ENDCASE
  598.   CASE "CALAN"
  599.     ASSIGN S1 "CALAN"
  600.     EXECUTE "VERSA4.MNU"
  601.   ENDCASE
  602.   CASE "CAPAL"
  603.     ASSIGN S1 "CAPAL"
  604.     EXECUTE "VERSA4.MNU"
  605.   ENDCASE
  606.   CASE "ORPOR"
  607.     ASSIGN S1 "ORPOR"
  608.     EXECUTE "VERSA4.MNU"
  609.   ENDCASE
  610.   CASE "CARIV"
  611.     ASSIGN S1 "CARIV"
  612.     EXECUTE "VERSA4.MNU"
  613.   ENDCASE
  614.   CASE "CASAC"
  615.     ASSIGN S1 "CASAC"
  616.     EXECUTE "VERSA4.MNU"
  617.   ENDCASE
  618.   CASE "CASAD"
  619.     ASSIGN S1 "CASAD"
  620.     EXECUTE "VERSA5.MNU"
  621.   ENDCASE
  622.   CASE "CASFA"
  623.     ASSIGN S1 "CASFA"
  624.     EXECUTE "VERSA5.MNU"
  625.   ENDCASE
  626.   CASE "CASJO"
  627.     ASSIGN S1 "CASJO"
  628.     EXECUTE "VERSA5.MNU"
  629.   ENDCASE
  630.   CASE "CASAN"
  631.     ASSIGN S1 "CASAN"
  632.     EXECUTE "VERSA5.MNU"
  633.   ENDCASE
  634.   CASE "WASEA"
  635.     ASSIGN S1 "WASEA"
  636.     EXECUTE "VERSA5.MNU"
  637.   ENDCASE
  638.   DEFAULT                     ;This occurs if user enters unknown city code
  639.     LOCATE 21,7               ;Locate for message, beep
  640.     MESSAGE "^GUnknown city code.  Continue or Go back to city selection <C/G>?"
  641.     LABEL3:                   ;Loop to here in case of erroneous input
  642.     LOCATE 21,72              ;Locate for user input
  643.     GET S9 1                  ;Get user input (1 character)
  644.     SWITCH S9                 ;Decision based on S9 (user input)
  645.       CASE "C"                ;User wants to continue,
  646.         EXECUTE "VERSA5.MNU"  ; so go ahead and display spare menu
  647.       ENDCASE
  648.       CASE "G"                ;User wants to go back,
  649.         GOTO CITYCHOICE       ; so go to CITYCHOICE
  650.       ENDCASE
  651.       CASE "D"                ;User wants to disconnect,
  652.         GOTO PCPOFF           ; so go to PCPOFF
  653.       ENDCASE
  654.       CASE "E"                ;User wants to exit,
  655.         CLEAR                 ; so clear the screen,
  656.         GOTO VERSAOFF         ; and go to VERSAOFF
  657.       ENDCASE
  658.       DEFAULT                 ;Erroneous input
  659.         LOCATE 21,72          ; locate cursor,
  660.         MESSAGE "^G "         ; beep and erase erroneous input,
  661.         GOTO LABEL3           ; and redo the GET
  662.       ENDCASE
  663.     ENDSWITCH                 ;End of decision based on user input
  664.   ENDCASE
  665. ENDSWITCH                     ;End of decision based on city code
  666.  
  667.  
  668.  
  669. ; ===== LEVEL1 ===============
  670. ;LEVEL1 is used to dial the local Telenet number and make a connection.  If
  671. ;for some reason the local Telenet number does not connect, LEVEL1 will
  672. ;display a message and automatically redial.  Once Telenet connects, LEVEL1
  673. ;sends two slow <CR>s for auto baud detection and issues D1 at the terminal
  674. ;type prompt.  LEVEL1 always "falls through" to LEVEL2.
  675.  
  676. LEVEL1:
  677. CLEAR                    ;Clear screen
  678. TRANSMIT "AT S2=42 DT "  ;Send command to dial local modem, reset escape char
  679. MACRO 7                  ;Send local Telenet phone number
  680. WAITFOR "CONNECT" 20     ;Wait 20 seconds for modem to send "CONNECT"
  681. IF NOT WAITFOR           ;If modem does not connect,
  682.   HANGUP                 ; hang up the phone line,
  683.   CLEAR                  ; clear screen,
  684.   LOCATE 11,19           ; locate the cursor for message,
  685.   MESSAGE "Local Telenet did not connect.  Redialing."
  686.   LOCATE 0,0             ; locate cursor out of the way,
  687.   PAUSE 1                ; allow user to see message,
  688.   GOTO LEVEL1            ; loop to beginning to dial again
  689. ENDIF                    ;When Local Telenet is connected with,
  690. PAUSE 2                  ; wait for connection to be properly made,
  691. TRANSMIT "!"             ; send first <CR>,
  692. PAUSE 1                  ; pause to allow auto baud detection to work,
  693. TRANSMIT "!"             ; send second <CR>,
  694. WAITFOR "="              ; wait for "TERMINAL TYPE =" prompt,
  695. TRANSMIT "D1!"           ; terminal type D1 is for PCs,
  696. WAITFOR "@"              ; wait for Telenet prompt
  697.  
  698.  
  699.  
  700. ;========== LEVEL2 ==========
  701. ;Once local Telenet is connected with, LEVEL2 is used to connect with a remote
  702. ;city.  LEVEL2 first makes sure that Telenet hasn't dropped carrier (if it
  703. ;has, LEVEL2 will go back to LEVEL1).  LEVEL2 will branch to NETDIAL if the
  704. ;current city code is NETEX.  LEVEL2 will dial a city, and if connected, will
  705. ;go to PORTSET.  If not connected, LEVEL2 will go to CITYREDIAL if the user
  706. ;wishes to redial or to CITYCHOICE if the user doesn't.  Since user input is
  707. ;obtained, LEVEL2 will branch to PCPOFF if the user enters "D" or to VERSAOFF
  708. ;if the user enters "E".
  709.  
  710. LEVEL2:
  711. IF NOT CONNECTED     ;If Telenet has dropped carrier,
  712.   CLEAR              ; clear screen,
  713.   LOCATE 11,7        ; locate the cursor for message,
  714.   MESSAGE "Telenet has disconnected.  Dialing will begin at the local level."
  715.   LOCATE 0,0         ; locate the cursor out of the way,
  716.   PAUSE 1            ; allow user to see the message,
  717.   ASSIGN S0 "1"      ; level is now 1
  718.   GOTO LEVEL1        ; start dialing from the beginning
  719. ENDIF
  720. ASSIGN S0 "2"        ;Otherwise, level is now 2
  721. FIND S1 "NETEX"      ;Check to see if user is calling the Net Exchange
  722. IF FOUND             ;If so,
  723.   GOTO NETDIAL       ; go to NETDIAL
  724. ENDIF
  725. TRANSMIT "C D/"      ;Send beginning of city dial command
  726. TRANSMIT S1          ;Send city code to be dialed
  727. MACRO 8              ;Send PCP baud rate
  728. MACRO 9              ;Send user ID
  729. WAITFOR "="          ;Wait for "PASSWORD ="
  730. MACRO 0              ;Send user password
  731. RGET S8              ;Get first <CR>
  732. RGET S8              ;Get second <CR>
  733. RGET S8              ;Get message
  734. FIND S8 "CONNECTED"  ;Look for "CONNECTED" in S8
  735. IF FOUND             ;If found city is connected so
  736.   MESSAGE "^G"       ; beep,
  737.   GOTO PORTSET       ; go to PORTSET
  738. ENDIF
  739. CLEAR                ;Otherwise, clear screen
  740. LOCATE 11,11         ;Locate cursor for message
  741. MESSAGE "No modems available in remote city.  Begin redial <Y/N>?"
  742. LABEL4:              ;Loop to here in case of erroneous input
  743. LOCATE 11,68         ;Locate cursor for user input
  744. GET S9 1             ;Get user input (1 character)
  745. SWITCH S9            ;Decision based on S9 (user input)
  746.   CASE "Y"           ;If the user enters "Y",
  747.     GOTO CITYREDIAL  ; redial the city
  748.   ENDCASE
  749.   CASE "N"           ;If the user enters "N",
  750.     GOTO CITYCHOICE  ; another city must be selected
  751.   ENDCASE
  752.   CASE "D"           ;If the user enters "D",
  753.     GOTO PCPOFF      ; PCPOFF will take care of the disconnection
  754.   ENDCASE
  755.   CASE "E"           ;If the user enters "E",
  756.     CLEAR            ; clear screen,
  757.     GOTO VERSAOFF    ; exit VERSA
  758.   ENDCASE
  759.   DEFAULT            ;Erroneous input
  760.     LOCATE 11,68     ;Locate the cursor,
  761.     MESSAGE "^G "    ; beep and erase the erroneous input,
  762.     GOTO LABEL4      ; redo the GET
  763.   ENDCASE
  764. ENDSWITCH            ;End of decision based on user input
  765.  
  766.  
  767.  
  768. ; ===== PORTSET ==============
  769. ;PORTSET is done once after a remote city has been connected with.  It
  770. ;always "falls through" to LEVEL3 when it is finished.  It is used to set
  771. ;three of Telenet's SET commands.  The three SETs are as follows:
  772. ;SET 1:0 disables escaping to command mode with <CR> @ <CR>
  773. ;SET 4:2 forces Telenet to send unfilled packets after .1 second
  774. ;SET 7:8 enables escaping to command mode with a break
  775. ;To learn why these SETs are advantageous, consult your PCP documentation.
  776.  
  777. PORTSET:
  778. TRANSMIT "!@!"                ;Get back to Telenet prompt
  779. WAITFOR "@"                   ;When it appears,
  780. TRANSMIT "SET? 1:0,4:2,7:8!"  ; do the SETs
  781. WAITFOR "@" 3                 ;Wait for Telenet prompt
  782. TRANSMIT "CONT!"              ;Go back to Hayes mode
  783.  
  784.  
  785.  
  786. ; ===== LEVEL3 ===============
  787. ;LEVEL3 is the level of dialing done once a remote city has been connected
  788. ;with and the SETs have been done.  It first tests to make sure PCP is still
  789. ;connected; if it is not, it starts over at CITYCHOICE if the selected city
  790. ;is unknown, or at LEVEL1 if the selected city is known.  If a modem is in
  791. ;Racal/Vadic mode, LEVEL3 will call R/V_MODE to reset it.  LEVEL3 dials the
  792. ;selected BBS number, and if it connects, branches to BBSCONNECT.  If the BBS
  793. ;does not connect, it branches to BBSREDIAL if the user wishes to redial or
  794. ;to MENUBRANCH if the user doesn't.  Since user input is accepted, "D" and
  795. ;"E" are also options, which branch to PCPOFF and VERSAOFF, respectively.
  796.  
  797. LEVEL3:
  798. IF NOT CONNECTED           ;If Telenet has dropped carrier,
  799.   CLEAR                    ; clear screen
  800.   LOCATE 11,7              ; locate cursor for message,
  801.   MESSAGE "Telenet has disconnected.  Dialing will begin at the local level."
  802.   LOCATE 0,0               ; locate cursor out of the way,
  803.   PAUSE 1                  ; allow user to see message
  804.   ASSIGN S0 "1"            ; level is now 1
  805.   GOTO LEVEL1              ; start dialing
  806. ENDIF                      ;End of IF NOT CONNECTED routine
  807. ASSIGN S0 "3"              ;Otherwise, level is now 3
  808. TRANSMIT "ATZ!"            ;Reset remote modem
  809. RGET S8 80 3               ;Get first <CR>
  810. RGET S8 80 3               ;Get second <CR>
  811. RGET S8 80 3               ;Get message
  812. FIND S8 "OK"               ;Look for "OK" in S8
  813. IF NOT FOUND               ;If no "OK" is found, assume R/V mode response
  814.   GOSUB R/V_MODE           ; so go to R/V_MODE
  815. ENDIF
  816. TRANSMIT "ATDT "           ;Send beginning of Hayes dialing command
  817. TRANSMIT S2                ;Send telephone number to dial
  818. TRANSMIT "!"               ;Send <CR> to complete command
  819. RGET S8                    ;Get first <CR>
  820. RGET S8 80 50              ;Wait a maximum of 50 seconds for second <CR>
  821. RGET S8                    ;Get message
  822. FIND S8 "CONNECT"          ;Look for "CONNECT" in S8
  823. IF FOUND                   ;If found, BBS has been connected,
  824.   GOTO BBSCONNECT          ; go to BBSCONNECT
  825. ENDIF
  826. CLEAR                      ;Otherwise, clear screen,
  827. LOCATE 11,20               ; locate the cursor for message
  828. MESSAGE "The BBS is busy.  Begin redial <Y/N>?"
  829. LABEL5:                    ;Loop to here in case of erroneous input
  830. LOCATE 11,58               ;Locate the cursor for user input
  831. GET S9 1                   ;Get user input (1 character)
  832. SWITCH S9                  ;Decision based on S9 (user input)
  833.   CASE "Y"                 ;If the user enters "Y",
  834.     GOTO BBSREDIAL         ; redial the BBS
  835.   ENDCASE
  836.   CASE "N"                 ;If the user enters "N",
  837.     ASSIGN S7 "*"          ; clear the old linked command file,
  838.     GOTO MENUBRANCH        ; and go to MENUBRANCH
  839.   ENDCASE
  840.   CASE "D"                 ;If the user enters "D",
  841.     GOTO PCPOFF            ; PCPOFF will take care of the disconnection
  842.   ENDCASE
  843.   CASE "E"                 ;If the user enters "E",
  844.     CLEAR                  ; clear the screen,
  845.     GOTO VERSAOFF          ; exit VERSA
  846.   ENDCASE
  847.   DEFAULT                  ;Erroneous input
  848.     LOCATE 11,58           ;Locate the cursor,
  849.     MESSAGE "^G "          ; beep and erase the erroneous input,
  850.     GOTO LABEL5            ; and redo the GET
  851.   ENDCASE
  852. ENDSWITCH                  ;End of decision based on user input
  853.