; DJDEMO.ASP - A PROCOMM PLUS ASPECT script command file to demo
;              various capabilities of the ASPECT command language
;              and the DOW JONES NEWS RETRIEVAL service.
;
;  (C) 1987 DATASTORM TECHNOLOGIES, INC.
;
;  This script file uses the following string variables:
;
;  S0 - Telenet number
;  S1 - Password
;  S8 - Subroutine parameter
;  S9 - Menu options
;
;  N1 - Normal Color
;  N2 - Bold Color
;  N3 - Reverse Color
;  N4 - Attention Color
;
;  Be sure to customize this .ASP file before use by entering
;  your local TELENET telephone number and DJNR password below.
;
;
ASSIGN S0 "xxx-xxxx"       ; **** enter your local TELENET number here
ASSIGN S1 "pppppppppp"     ; **** enter your PASSWORD here

IF MONO                    ; set colors for different monitors
   INIT N1 7               ; Normal
   INIT N2 15              ; Bold
   INIT N3 112             ; Reverse
   INIT N4 112             ; attention
ELSE
   INIT N1 23
   INIT N2 31
   INIT N3 113
   INIT N4 78
ENDIF

EMULATE ANSI               ; Select terminal emulation
SET SOFTFLOW ON            ; Turn on software flow control

GOTO MAIN                  ; Jump to main loop

;
; SUBROUTINE AREA
;

;
; ERRORMSG - Prints the error message in variable S8 and beeps
;
ERRORMSG:
   SCROLL 0 19 22 19 58 N2
   ATSAY 19 22 N2 S8
   SOUND 440 50
   PAUSE 1
RETURN

;
; LOGON - Logs you on to DOW JONES
;
LOGON:
   CLEAR  N1
   TIME S8 0
   DATE S9
   FATSAY 0 0 N2 "Dialing Dow Jones News Retrieval at %s on %s" S8 S9
   SET BAUD 1200            ; configure line settings
   SET PARITY EVEN
   SET DATABITS 7
   SET DUPLEX FULL
   MDIAL S0                 ; Dial TELENET

   PAUSE 2                    ; Wait a sec for network
   TRANSMIT "^M^M"            ; Wake up TELENET
   WAITFOR "TERMINAL="        ; Wait for prompt
   TRANSMIT "^M"              ; Send CR
   WAITFOR "@"                ; Wait for prompt
   TRANSMIT "C DOW^M"         ; Send SYSTEM ID
   WAITFOR "PLEASE????"       ; Wait for prompt
   TRANSMIT "DJNS^M"          ; Send service id
   WAITFOR "PASSWORD"         ; Wait for prompt
   TRANSMIT S1                ; Send password
   TRANSMIT "^M"              ; and CR
   WAITFOR "QUERY"
   TRANSMIT "^M"              ; and CR
   WAITFOR "DATA-BASE CODE"
   PAUSE 2
   RFLUSH
RETURN

;
; The MAIN PROCESSING loop
;
MAIN:

   SET DISPLAY OFF
   RFLUSH
   CUROFF
   CLEAR
   BOX 5 20 17 60 N2
   ATSAY 5 22 N3 "    DOW JONES NEWS RETRIEVAL DEMO    "

;
; The menu below displays valid options highlighted
;

   IF CONNECTED
      ATSAY 7 22 N1 "A- Log onto DOW JONES NEWS RETRIEVAL"
      ATSAY 9 22 N2 "B- Check IBM and other computer stocks"
      ATSAY 11 22 N2 "C- Read a DJNEWS item about Microsoft"
      ATSAY 13 22 N2 "X- Log off DOW JONES NEWS RETRIEVAL"
      ATSAY 17 31 N4 "  You are ON-LINE  "
   ELSE
      ATSAY 7 22 N2 "A- Log onto DOW JONES NEWS RETRIEVAL"
      ATSAY 9 22 N1 "B- Check IBM and other computer stocks"
      ATSAY 11 22 N1 "C- Read a DJNEWS item about Microsoft"
      ATSAY 13 22 N2 "X- Exit this ASPECT Command File"
      ATSAY 17 31 N4 "  You are OFF-LINE "
   ENDIF

   ATSAY 15 22 N2 "Please press a key:  "
   LOCATE 15 42
   RFLUSH
   SET DISPLAY ON
   CURON

   SET MENUMODE ON
   KEYGET S9
   SET MENUMODE OFF
   SWITCH S9
      CASE "A"
         IF CONNECTED
            ASSIGN S8 "You are already connected!"
            GOSUB ERRORMSG
         ELSE
            GOSUB LOGON
         ENDIF
      ENDCASE
      CASE "B"
         IF CONNECTED
            CLEAR
            TRANSMIT "//CQE^M"
            WAITFOR "ENTER QUERY"
            PAUSE 1
            TRANSMIT "IBM MSFT LOTS TATE DELL^M"
            WAITFOR "   " 15
            MESSAGE " "
            MESSAGE "Press any key to continue"
            KEYGET S9
         ELSE
            ASSIGN S8 "You must be on-line first!"
            GOSUB ERRORMSG
         ENDIF
      ENDCASE
      CASE "C"
         IF CONNECTED
            CLEAR
            TRANSMIT "//DJNEWS^M"
            WAITFOR "ENTER REQUEST"
            PAUSE 2
            WHEN "PRESS RETURN FOR MORE" "^M"
            TRANSMIT ".MSFT^M"
            WAITFOR "ENTER ANOTHER REQUEST" 300
            MESSAGE " "
            MESSAGE "Press any key to continue"
            KEYGET S9
         ELSE
            ASSIGN S8 "You must be on-line first!"
            GOSUB ERRORMSG
         ENDIF
      ENDCASE
      CASE "X"
         IF CONNECTED
            CLEAR
            MESSAGE "Logging off DOW JONES NEWS RETRIEVAL"
            MESSAGE " "
            TRANSMIT "DISC^M"
            WAITFOR "DOW DISCONNECTED"
            HANGUP
         ELSE
            CLEAR
            MESSAGE "Thank you for using PROCOMM PLUS and DOW JONES NEWS RETRIEVAL"
            EXIT
         ENDIF
      ENDCASE
   ENDSWITCH

   GOTO MAIN
