; docs?  See Bottom of file.
; NOTE:  [IR#000]'s are found throughout this file.  They are used
;        by the ACONFIG.COM configuration/optimizer.  DO NOT ALTER.
 IF LINKED
   MESSAGE"AAAPCP: File MUST NOT be linked with dialing directory."
   MESSAGE"        Issue ALT-F5 A <ENTER> to use AAAPCP+."
   HANGUP
   EXIT
 ENDIF
 STRCPY S3"12"                   ;REPLACE w/ /baud
 STRCPY S8",abc00340,abcd0340^m" ;REPLACE",id,pw^m"   [IR#001]
 GOTO START:                     ;jump to start/restart
C_DIAL:
 FIND S9"Y"
 IF FOUND                     ;  IF repeat flag is ON
   ATSAY 00 23 N0" ¯ Press SPACE to abort REPEAT ® "
   SET MENUMODE ON            ;   KEEP KEYSTROKES FOR ABORT OPTION
 ENDIF
 SWITCH S0                    ;switch user request (A/P/AREA)
  CASE"A"                     ; case ADDRESS
   STRCPY S7 "c "             ;  setup ADDRESS transmit string
   STRCAT S7 S2               ;   address
   STRCAT S7 S8               ;   id/pw
   FIND S2"PURSUIT"           ;  if (SEND=PURSUIT BBS)
   IF FOUND
    STRCPY S7 "c "            ;   setup ADDRESS transmit string
    STRCAT S7 S2              ;    address
    STRCAT S7 "^m"
   ENDIF 
   GOSUB PCPADD               ;  gosub ADDRESS login routine
  ENDCASE
  DEFAULT                     ; case NON-ADDRESS (PORT)
   STRCPY S7 "c d/"           ;  setup PORT transmit string
   STRCAT S7 S2               ;   city
   STRCAT S7 "/"
   STRCAT S7 S4               ;   baud
   STRCAT S7 S8               ;   id/pw
   GOSUB PCP_PORT             ;  gosub PORT login routine
  ENDCASE
 ENDSWITCH
 RETURN
;
PCP_PORT:                     ;ROUTINE: c d/xxxxx/bd,id,pw
 IF NOT CONNECTED  ;if(carrier lost)
  MESSAGE"^MAAAPCP: Carrier Lost.  Redialing..."
  GOSUB DIAL_UP
 ENDIF
 IF HITKEY                    ; IF KEY PRESSED(ABORT=Y)
   KFLUSH
   SET MENUMODE OFF           ;  ALLOW keys to go to output again
   STRCPY S9"A"               ;  FLAG REPEAT ABORT
 ENDIF
 TRANSMIT S7                  ; TRANSMIT request
 RGET S5 80 11                ; Get line #1
 RGET S1 80 11                ; Get line #2
 IF NOT SUCCESS               ; Check to make sure Telenet is alive
   ALARM
   MESSAGE"AAAPCP: Telenet Appears Frozen.  Disconnecting..."
   MESSAGE"AAAPCP: Aborting Request to prevent loop."
   SET MENUMODE OFF           ;  turn on keyboard
   HANGUP
   GOSUB DIAL_UP              ;  dial back into telenet
   STRCPY S1"Request ABORTED due to "
   STRCPY S5"Telenet Port Freeze."
   RETURN
 ENDIF
 RGET S5                      ; Get line #3
 FIND S5"CONNECT"             ; Look for connection
 IF NOT FOUND                 ; IF NO CONNECTION
  FIND S9"Y"
  IF FOUND                    ;  IF repeat flag is ON
   GOTO PCP_PORT              ;   GO BACK and try again (infinite loop)
  ENDIF
 ENDIF
 FIND S5"CONN"                ; IF CONNECTION
 IF FOUND
  ALARM                       ;  sound alarm
  EXIT                        ;  exit to term mode
 ENDIF
 RETURN
;
PCPADD:                       ;ROUTINE: c xxxxx,id,pw
 IF NOT CONNECTED ;if(carrier lost)
  MESSAGE"^MAAAPCP: Carrier Lost.  Redialing..."
  GOSUB DIAL_UP
 ENDIF
 IF HITKEY                    ; IF KEY PRESSED(ABORT=Y)
   KFLUSH
   SET MENUMODE OFF           ;  ALLOW keys to go to output again
   STRCPY S9"A"               ;  FLAG REPEAT ABORT
 ENDIF
 TRANSMIT S7                  ; TRANSMIT request
 RGET S5 80 11                ; Get line #1
 RGET S1 80 11                ; Get line #2
 IF NOT SUCCESS               ; Check to make sure Telenet is alive
   ALARM
   MESSAGE"AAAPCP: Telenet Appears Frozen.  Disconnecting..."
   MESSAGE"AAAPCP: Aborting Request to prevent loop."
   SET MENUMODE OFF           ;  turn on keyboard
   HANGUP
   GOSUB DIAL_UP              ;  dial back into telenet
   STRCPY S1"Request ABORTED due to "
   STRCPY S5"Telenet Port Freeze."
   RETURN
 ENDIF
 RGET S5                      ; Get line #3
 FIND S5"CONNECT"             ; Look for connection
 IF NOT FOUND                 ; IF NO CONNECTION
  FIND S9"Y"
  IF FOUND                    ;  IF repeat flag is ON
   GOTO PCP_PORT              ;   GO BACK and try again (infinite loop)
  ENDIF
 ENDIF
 FIND S5"CONN"                ; IF CONNECTION
 IF FOUND
  ALARM                       ;  sound alarm
  EXIT                        ;  exit to term mode
 ENDIF
 RETURN
;
START:                        ;STARTUP
 STRCPY S1"Restart/Connected" ; assume restart
 STRCPY S2" "                 ; set last request area to nothing
 INIT N0 14                   ; Color bright yellow
 INIT N1 1                    ; Color dark blue
 INIT N2 2                    ; Color green
 INIT N3 3                    ; Color cyan
 INIT N4 4                    ; Color red
 INIT N5 5                    ; Color magenta
 INIT N6 6                    ; Color brown
 INIT N7 7         ;unused    ; Color white
 INIT N8 8         ;unused    ; Color grey
 INIT N9 9                    ; Color light blue
MENU_A:
 IF NOT CONNECTED             ; IF NO CARRIER
  CLEAR                       ;  clear screen
  GOSUB DIAL_UP               ;  GOSUB connect to telenet
 ENDIF
 CLEAR                        ; clear screen
 SET DISPLAY OFF              ; turn incoming character display off
 BOX 00 00 23 79 N1           ; draw box
 ATSAY 01 02 N4"nnnn ST Cty Comments"
 ATSAY 00 24 N1"¹ "
 ATSAY 00 26 N2"AAAPCP+ "
 ATSAY 00 34 N0"v3.4 "
 ATSAY 00 39 N4"by Paul Johnson "
 ATSAY 00 55 N1"Ì"
 ATSAY 01 55 N4"MultiComm 815/282-1494"
 ATSAY 01 29 N2"312  IL Chi[1815     ]"                           
 ATSAY 02 02 N2"201  NJ New[         ]     313  MI Det[         ]    617  MA Bos[         ]"
 ATSAY 03 02 N2"202  DC Was[301;703*7]     314  MO SLo[1618     ]    619  CA SDi[         ]"
 ATSAY 04 02 N2"203  CT Har[         ]     404  GA Atl[         ]    713  TX Hou[         ]"
 ATSAY 05 02 N2"206  WA Sea[         ]     408  CA SJo[         ]    714  CA SAn[         ]"
 ATSAY 06 02 N2"212  NY NYo[1718     ]     414  WI Mil[         ]    7142 CA Col[         ]"
 ATSAY 07 02 N2"213  CA LAn[         ]     415  CA SFa[         ]    801  UT SLC[         ]"
 ATSAY 08 02 N2"214  TX Dal[817   *10]     4152 CA Oak[         ]    813  FL Tam[         ]"
 ATSAY 09 02 N2"215  PA Phi[         ]     4153 CA PAl[         ]    816  MO KCi[1913     ]"
 ATSAY 10 02 N2"216  OH Cle[         ]     503  OR Por[         ]    818  CA Gle[         ]"
 ATSAY 11 02 N2"303  CO Den[         ]     602  AZ Pho[         ]    916  CA Sac[         ]"
 ATSAY 12 02 N2"305  FL Mia[         ]     612  MN Min[         ]    919  NC RTP[         ]"
 ATSAY 13 00 N1"ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
 ATSAY 13 40 N1"ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¶"
 ATSAY 14 02 N2"A    C aaaaaaa,id,pw    (ex. execpc)            A:   plink,pursuit,execpc,"
 ATSAY 15 02 N2"nnnn C D/ppppp/bb,id,pw (ex. 4153)                   portal,31256.06,delphi"
 ATSAY 16 02 N2"P    C D/ppppp/bb,id,pw (ex. casac)             *7   Dial 7 Digits"
 ATSAY 14 02 N6"A"
 ATSAY 15 02 N0"nnnn"
 ATSAY 16 02 N6"P"
 ATSAY 17 00 N1"ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
 ATSAY 17 40 N1"ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¶"
 FATSAY 18 02 N2"Last Port Request:  %s,%s/%s" S0 S2 S4
 FATSAY 19 02 N3"Status Message   :  %-.26s%-.26s" S1 S5
 ATSAY 20 02 N0"nnnn"
 FATSAY 20 06 N4"/A/P/X<ENTER>:  %s" S6
 FATSAY 21 02 N5"Baud    (3,12,24):  %s" S3
 ATSAY 22 02 N6"Repeat  (Def=n)  :"
;
GET_AREA:                     ;get user request for destination
 ATGET 20 22 N4 4 S0          ; Get S0 AREA
 SWITCH S0
  CASE "_NULL"                ; CASE: <ENTER>
   STRCPY S0 S6               ;  copy last AREA into AREA
  ENDCASE
  CASE "X"                    ; CASE: exit
   CLEAR
   MESSAGE"AAAPCP: Disconnecting Telenet"
   HANGUP
   GOSUB INFBOX               ;  gosub aaapcp info box routine
   MESSAGE "^M"               ;  move cursor below box
   EXIT                       ;  exit to term
  ENDCASE
 ENDSWITCH
;
 FATSAY 20 22 N4"%-55s" S0    ; display AREA & Clear AREA error message
 STRCPY S6 S0                 ; set new last AREA
;
 SWITCH S0                    ; switch AREA
  CASE"201"
   STRCPY S2"njnew"
  ENDCASE
  CASE"202"
   STRCPY S2"dcwas"
  ENDCASE
  CASE"203"
   STRCPY S2"cthar"
  ENDCASE
  CASE"206"
   STRCPY S2"wasea"
  ENDCASE
  CASE"212"
   STRCPY S2"nynyo"
  ENDCASE
  CASE"213"
   STRCPY S2"calan"
  ENDCASE
  CASE"214"
   STRCPY S2"txdal"
  ENDCASE
  CASE"215"
   STRCPY S2"paphi"
  ENDCASE
  CASE"216"
   STRCPY S2"ohcle"
  ENDCASE
  CASE"303"
   STRCPY S2"coden"
  ENDCASE
  CASE"305"
   STRCPY S2"flmia"
  ENDCASE
  CASE"312"
   STRCPY S2"ilchi"
  ENDCASE
  CASE"313"
   STRCPY S2"midet"
  ENDCASE
  CASE"314"
   STRCPY S2"moslo"
  ENDCASE
  CASE"404"
   STRCPY S2"gaatl"
  ENDCASE
  CASE"408"
   STRCPY S2"casjo"
  ENDCASE
  CASE"414"
   STRCPY S2"wimil"
  ENDCASE
  CASE"415"
   STRCPY S2"casfa"
  ENDCASE
  CASE"4152"
   STRCPY S2"caoak"
  ENDCASE
  CASE"4153"
   STRCPY S2"capal"
  ENDCASE
  CASE"503"
   STRCPY S2"orpor"
  ENDCASE
  CASE"602"
   STRCPY S2"azpho"
  ENDCASE
  CASE"612"
   STRCPY S2"mnmin"
  ENDCASE
  CASE"617"
   STRCPY S2"mabos"
  ENDCASE
  CASE"619"
   STRCPY S2"casdi"
  ENDCASE
  CASE"713"
   STRCPY S2"txhou"
  ENDCASE
  CASE"714"
   STRCPY S2"casan"
  ENDCASE
  CASE"7142"
   STRCPY S2"cacol"
  ENDCASE
  CASE"801"
   STRCPY S2"utslc"
  ENDCASE
  CASE"813"
   STRCPY S2"fltam"
  ENDCASE
  CASE"816"
   STRCPY S2"mokci"
  ENDCASE
  CASE"818"
   STRCPY S2"cagle"
  ENDCASE
  CASE"919"
   STRCPY S2"ncrtp"
  ENDCASE
  CASE"916"
   STRCPY S2"casac"
  ENDCASE
  CASE"A"                     ;  CASE: A)ddress
   STRCPY S4" "               ;   clear transmit baud
   ATSAY 21 22 N5"N/A"        ;   display the fact that baud is N/A
   ATSAY 20 22 N4"Manual Address?  [__________]"
   ATGET 20 40 N4 10 S2       ;   get user address to transmit
   GOTO NO_BAUD               ;   skip past baud input code
  ENDCASE
  CASE"P"                     ;  CASE: P)ort
   ATSAY 20 22 N4"Manual Port Name? >_____<"
   ATGET 20 41 N4 5 S2        ;   get user port city code
  ENDCASE
  DEFAULT                     ;  CASE: ERROR (ie all others)
   ATSAY 20 40 N4"Please Enter nnnn, A, P, or X."
   SOUND 612 12               ;   sound an error noise
   GOTO GET_AREA              ;   go back and let user try again
  ENDCASE
 ENDSWITCH
;
GET_BAUD:                     ;GET user baud request or <ENTER>
 ATGET 21 22 N5 2 S4          ; Get Baud input
 ATSAY 21 40 000"                           " ;Clear Error
 SWITCH S4                    ; SWITCH BAUD
  CASE"3"                     ;  CASE: 3
  ENDCASE
  CASE"12"                    ;  CASE: 12
  ENDCASE
  CASE"24"                    ;  CASE: 24
  ENDCASE
  CASE"_NULL"                 ;  CASE: <ENTER>
   STRCPY S4 S3               ;   copy last/default into current BAUD
   FATSAY 21 22 N5"%s" S4     ;   display BAUD
  ENDCASE
  DEFAULT                     ;  CASE: NOT 3, 12, 24, or <ENTER>
   ATSAY 21 40 N5"Please Enter 3, 12, or 24"
   SOUND 612 12               ;   sound error noise
   GOTO GET_BAUD              ;   go let user try to enter BAUD again
  ENDCASE
 ENDSWITCH
 STRCPY S3 S4                 ; set LAST baud to CURRENT baud
;
NO_BAUD:                      ;LABEL to jump to when BAUD is N/A
 ATGET 22 22 N6 1 S9          ; get repeat y/N
 SET DISPLAY ON               ; turn incoming character display on again
 CLEAR                        ; clear screen
 IF NOT CONNECTED             ; IF CARRIER LOST
  GOSUB C_DIAL                ;  GOSUB Routine to switch request type
 ELSE                         ; ELSE
  TRANSMIT"^m" ;clear input/scan for twits
  WAITFOR"?" 2                ;  handshake with telenet
  IF NOT WAITFOR              ;  IF expected handshake not found
   MESSAGE "^MAAAPCP: @ Not Found.  Attempting City Disconnect."
   TRANSMIT "^M@^MD^M"        ;   TRANSMIT city disconnect string
   PAUSE 1                    ;   pause 1 second
   TRANSMIT "^M"              ;   handshake with telenet
   WAITFOR"?" 3               ;   IF expected handshake not found
   IF NOT WAITFOR
    MESSAGE "^MAAAPCP: Attempt Failed:  Telenet Appears Frozen."
    MESSAGE "AAAPCP: Disconnecting Telenet"
    HANGUP                    ;    HANGUP and call back
   ENDIF
  ENDIF
  GOSUB C_DIAL                ; GOSUB routine to switch request type
 ENDIF
 GOTO MENU_A                  ; GOTO menu, diplay response, & get next
;
DIAL_UP:                      ;CONNECT TO TELENET
 GOSUB INFBOX                 ; display aaapcp info box
 SET DATABITS 8    ;REPLACE 7/8
 SET BAUDRATE 2400 ;REPLACE baud   [IR#002]
 SET PARITY NONE   ;REPLACE NONE/EVEN
 MESSAGE"^J^MAAAPCP: Dialing Telenet..."
L2:
 TRANSMIT "ATDT965-0696^m"  ;REPLACE ACCESS #   [IR#003]
 MLOAD"AAAPCP.KEY"          ;REPLACE MACRO file
 SET TXPACE 0               ;REPLACE XMIT PACE
 SET DUPLEX FULL            ;REPLACE DUPLEX
 WAITFOR"CONNECT" 30        ;REPLACE the number of secounds of wait time
 IF NOT WAITFOR               ; it didn't connect, assume busy
  HANGUP
  MESSAGE"^MAAAPCP: Busy. Redialing..."
  PAUSE 2
  GOTO L2                     ; go dial again
 ENDIF
;
 PAUSE 2
 TRANSMIT"@~D~^m"           ; REPLACE with CORRECT handshake   [IR#004]
 WAITFOR"=" 6                 ; Wait for 'TERMINAL=' prompt
 IF NOT WAITFOR               ; IF handshake failed to wakeup Telenet
  MESSAGE"AAAPCP: Telenet Not Responding to Handshake.  Redialing..."
  MESSAGE"        If problem persists, see error message in docs."
  HANGUP                      ;  hangup
  PAUSE 1
  GOTO L2                     ;   go dial again
 ENDIF
 TRANSMIT"A1^m"               ; REPLACE terminal type A1,D1
 STRCPY S1"Initial Startup"
 ALARM                        ; sound connection to telenet alarm
 WAITFOR"@"                   ; Wait for Telenet prompt
 RETURN
;
INFBOX:                       ;DISPLAY INFO BOX
 CLEAR
 BOX 00 16 13 62 N9
 ATSAY 00 24 N9"¹ AAAPCP+ for ProComm+ v1.1a+ Ì"
 ATSAY 02 26 N0"If you find AAAPCP+ useful,"
 ATSAY 03 25 N2"PLEASE send $5.00 (I need it):"
 ATSAY 05 34 N5"Paul Johnson"
 ATSAY 06 30 N6"401 South 2nd Street"
 ATSAY 07 30 N4"Rockford, IL  61104"
 ATSAY 09 28 30"Unhappy with PC-Pursuit?"
 ATSAY 10 26 N2"Fill out and mail the Tymnet"
 ATSAY 11 26 N2"Questionnaire (PCPTYMNT.TXT)."
 RETURN
;-----------------------------------------------------------------------
; AAAPCP+    v2.3+Written 06/15/88 by Paul Johnson
;            v3.0 Written 08/22/88 by Paul Johnson
;            v3.4 Updated 01/29/89 by Paul Johnson
;Registers:
; S0 - User Request [nnnn/A/P/X] for switching & display
; S1 - Current Status or Response from last request for display
; S2 - PCP city code, port code, or address being xmitted
; S3 - Last Baud Called or default
; S4 - BAUD RATE being xmitted
; S5 - used to pick up unwanted response lines
; S6 - Last Area Called
; S7 - C Space Request w/ ID/PW to be transmitted
; S8 - User account/pass being xmitted
; S9 - 'y' 'n' to repeat
