home *** CD-ROM | disk | FTP | other *** search
- /* This REXX script will log you onto the FedWorld BBS and download */
- /* a set of weather maps in GIF format */
- /* by: Sam Shipley, Hilgraeve Inc. */
- /* $Revision: 1.1 $ */
- /* $Date: 1996/07/02 14:53:35 $ */
-
- /* Text within slashes and asterisks (like this line) are comments. */
- /* Parse the command line for arguments passed to this program */
- PARSE ARG pipename
-
- /******* Register external functions with REXX *****************************/
- CALL RxFuncAdd 'haLoadFuncs', 'HAP_AUTO', 'RxhaLoadFuncs'
- CALL haLoadFuncs
-
- signal on failure name CLEANUP
- signal on halt name CLEANUP
- signal on syntax name CLEANUP
-
- /************ Process only if link with HyperACCESS was successful ********/
- scripthandle = haInitialize(1, pipename)
- IF scripthandle <> 0 THEN
- DO
-
- /******************** Initialize useful variables **************************/
- cr = '0D'x
- lf = '0A'x
- nul = '00'x
- ErrMsg1 = "The BBS has displayed some unexpected text at line "
- ErrMsg2 = " of the script. The script will attempt to recover."
- ErrMsg3 = "Try calling again. If you still have problems check the"
- ErrMsg4 = " Hilgraeve BBS for a revised script."
- crlf = '0D'x||'0A'x
- returnvalue = 0
- MWSret = 0
- NameCnt = 0
- MapName = ''
- NameVal = ''
- Mname = ''
- Mcompany = ''
- Maddress = ''
- Mcity = ''
- Mphone = ''
- password = ''
- ErrCnt = 0
- RegisterData = haGetNameString(scripthandle, 256,'RegBuf')
- parse var RegBuf Name (crlf) Company (crlf) Address (crlf) City (crlf) State (crlf) Zip (crlf) Country
- City = City || "," || State || " " || Zip
-
- /****** Routine to check if this is a first time call to FedWorld BBS ******/
-
- ret = haGetRuntimeValue(scripthandle, 1, 0, 128, 'NameVal')
- /* If user has logged in using this script and has stored their name
- in the runtime values then NameVal will have a length greater than
- 0 */
-
- IF LENGTH(NameVal) > 0 THEN DO
- CALL StandardLogin
- END
- ELSE DO
- CALL NewUser
- END
- DO i = 1 TO 3 /* Send some carriage returns to clear any unwanted messages */
- returnvalue = haTypeText(scripthandle, 0, cr)
- ret = haWaitForActivity(scripthandle, 5000)
- END /* DO i = 1 TO 3 */
- /*** We'll now start making the selections to download the weather Maps ****/
- /* Check to see if one of the runtime values contains a map name */
- DO i = 10 TO 19
- returnvalue = haGetSessionDataString(scripthandle, i, 14, 'MapName')
- IF LENGTH(MapName) > 0 THEN LEAVE
- END
- IF LENGTH(MapName) > 0 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, '/go satimgs'||cr)
- CALL GetMaps
- END
- CALL Cleanup
- END
-
- /*********************** Subroutine section ********************************/
-
- NewUser:
-
- /******************* Start of opening screen *******************************/
-
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, '"NEW": ', 600000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'new'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForPrompt(scripthandle, 1, 'continue', 300, 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, cr)
-
- /************** BBS prompt to ask about ANSI graphics *********************/
-
- IF returnvalue >= 0 THEN
- returnvalue = haWaitForPrompt(scripthandle, 1, '[1D'||'1B'x'[37m', 300, 12000)
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'N'||cr)
-
- /************ Start logging in as a new user *******************************/
- DO UNTIL MWSret >= 8
- MWSret = haWaitForString(scripthandle, 9, 'tted!)'nul'if none:'nul'Box):'nul'ZIP):'nul'U.S.):'nul'the day:'nul'0 to 3:'nul'to use:'nul'verification'nul||nul, 180000)
- CALL ChkRtnVal
- SELECT
-
- /************* Get user name and pass to FedWorld BBS **********************/
- WHEN MWSret = 0 THEN
- DO
- IF NameCnt = 0 THEN DO
- returnvalue = haGetRuntimeValue(scripthandle, 1, 1, 128, 'NameVal')
- returnvalue = haTypeText(scripthandle, 0, NameVal||cr)
- returnvalue = haSetRuntimeValue(scripthandle, 1, NameVal)
- NameCnt = NameCnt + 1
- END
- ELSE DO
- returnvalue = haMessageBox(scripthandle, 'NAME IN USE!!','Please change name slightly and press OK', 128, 'Mname', 1)
- returnvalue = haTypeText(scripthandle, 0, Mname||cr)
- returnvalue = haSetRuntimeValue(scripthandle, 1, Mname)
- END
- END
-
- /*************** Get Company Name and pass to FedWorld BBS *****************/
- WHEN MWSret = 1 THEN
- DO
- IF LENGTH(Company) > 0 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, Company||cr)
- END
- ELSE DO
- returnvalue = haMessageBox(scripthandle, 'Company','Please enter your company name, press enter for none', 128, 'Mcompany', 1)
- returnvalue = haTypeText(scripthandle, 0, Mcompany||cr)
- END
-
- END
-
- /************ Get street address and pass to FedWorld BBS ******************/
- WHEN MWSret = 2 THEN
- DO
- IF LENGTH(Address) >= 5 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, Address||cr)
- END
- ELSE DO
- returnvalue = haMessageBox(scripthandle, 'Address','Please enter your address and press OK', 128, 'Maddress', 1)
- returnvalue = haTypeText(scripthandle, 0, Maddress||cr)
- END
- END
-
- /************* Get City, ST & Zip Code and pass to FedWorld BBS ***********/
- WHEN MWSret = 3 THEN
- DO
- IF LENGTH(City) >= 7 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, City||cr)
- END
- ELSE DO
- returnvalue = haMessageBox(scripthandle, 'City, State & Zip','Please enter your City, St and Postal Code then press OK', 128, 'Mcity', 1)
- returnvalue = haTypeText(scripthandle, 0, Mcity||cr)
- END
-
- END
-
- /*************** Enter Country ********************************************/
- WHEN MWSret = 4 THEN
- DO
- IF LENGTH(Country) >= 2 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, Country)
- END
- END
-
- /*************** Enter Daytime phone ***************************************/
- WHEN MWSret = 5 THEN
- DO
- returnvalue = haMessageBox(scripthandle, 'Phone Number','Please enter your daytime phone number and press OK', 128, 'Mphone', 1)
- returnvalue = haTypeText(scripthandle, 0, Mphone||cr)
- END
-
- /************** Enter type of computer *************************************/
- WHEN MWSret = 6 THEN
- returnvalue = haTypeText(scripthandle, 0, '1'||cr)
-
- /************** Enter Password *********************************************/
- WHEN MWSret = 7 THEN
- DO
- returnvalue = haGetRuntimeValue(scripthandle, 3, 1, 128, 'password')
- returnvalue = haTypeText(scripthandle, 0, password||cr)
- returnvalue = haSetRuntimeValue(scripthandle, 3, password)
- END
-
- /************** Verify Passowrd ********************************************/
- WHEN MWSret = 8 THEN
- DO
- returnvalue = haTypeText(scripthandle, 0, password||cr)
- END
-
- /************ Some other value has been returned - this is an error ********/
- OTHERWISE LEAVE
- END /* SELECT */
- END /* DO UNTIL */
-
- /* The rest will be answered with default answers to get to the main menu */
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'sword...', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, '(Y/N)? ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'n'||cr)
- returnvalue = 0
- RETURN
-
- StandardLogin:
- returnvalue = 0
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, '"NEW": ', 600000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haGetRuntimeValue(scripthandle, 1, 1, 128, 'NameVal')
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, NameVal || cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'Password> ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haGetRuntimeValue(scripthandle, 3, 1, 128, 'PassVal') >= 0 THEN
- IF returnvalue >= 0 THEN DO
- returnvalue = haTypeText(scripthandle, 0, PassVal||cr)
- returnvalue = haSetRuntimeValue(scripthandle, 3, PassVal)
- END
- DO UNTIL MWSret >= 1
- MWSret = haWaitForString(scripthandle, 2, 'RETURN to continue'nul' (Y/N)? 'nul||nul, 20000)
- SELECT
- WHEN MWSret = 0 THEN
- returnvalue = haTypeText(scripthandle, 0, cr)
- WHEN MWSret = 1 THEN
- returnvalue = haTypeText(scripthandle, 0, 'n'||cr)
- OTHERWISE LEAVE
- END /* SELECT */
- END /* DO UNTIL */
- MWSret = 0
- returnvalue = 0
- RETURN
-
- GetMaps:
-
- /******** Get the maps for downloading from the runtime values *************/
- /* GetMaps processes the list of files from the runtime values that the
- user selected with the MAPSELEC.CMD script which runs before the connection
- is started. */
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'help: ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'p'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'exit: ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'p'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'RETURN: ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'z'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'mplete? ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'n'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'to exit: ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'x'||cr)
- IF returnvalue >= 0 THEN
- returnvalue = haSetXferProtocol(scripthandle, 2, 2)
- Map. = ''
- DO i = 10 TO 19
- returnvalue = haGetSessionDataString(scripthandle, i, 14, 'Map.'i)
- END
- IF returnvalue >= 0 THEN
- DO i = 10 TO 19
- IF LENGTH(Map.i) > 1 THEN
- DO /* Start download of file */
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'D'||cr)
- IF returnvalue >= 0 THEN
- returnvalue = haWaitForString(scripthandle, 1, 'help', 12000)
- returnvalue = haTypeText(scripthandle, 0, Map.i||cr)
- IF returnvalue >= 0 THEN
- returnvalue = haWaitForString(scripthandle, 1, 'continue', 1000000)
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, cr)
- END /* End download of file */
- END /* i = 10 TO 19 loop */
-
- /***************** End the session and disconnect **************************/
-
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, 'for help: ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, '/go logoff'||cr)
- IF returnvalue >= 0 THEN DO
- returnvalue = haWaitForString(scripthandle, 1, '(Y/N)? ', 5000)
- CALL ChkRtnVal
- END
- IF returnvalue >= 0 THEN
- returnvalue = haTypeText(scripthandle, 0, 'Y'||cr)
- RETURN
-
-
- CLEANUP:
- ret = haDisconnectSession(scripthandle)
- CALL haTerminate scripthandle
- DROP pipename
- DROP scripthandle
- CALL haDropFuncs
- EXIT
-
- ChkRtnVal:
- retval = haGetConnectionStatus
- IF retval == 3 THEN CALL Cleanup
- IF returnvalue < 0 THEN DO
- IF ErrCnt = 0 THEN DO
- ErrCnt = 1
- returnvalue = haMessageBox(scripthandle, 'Error', ErrMsg1||sigl||ErrMsg2, 0, null, 1)
- END
- ELSE DO
- returnvalue = haMessageBox(scripthandle, 'Unrecoverable Error', ErrMsg3||ErrMsg4, 0, null, 1)
- CALL Cleanup
- END
- END
- RETURN