home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / haotd1_1.zip / APIHELP.TXT < prev    next >
Text File  |  1995-10-12  |  25KB  |  650 lines

  1. ------------------------------------------------------------
  2.           HyperACCESS for OS/2 API Examples
  3. ------------------------------------------------------------
  4.  
  5. API Examples
  6.  
  7. This file contains a series of REXX program code segments that 
  8. illustrate how to use most API functions. Each segment includes
  9. commentary that explains the purpose and reasoning behind the
  10. function calls. 
  11.  
  12. The program segments, below, don't include calls to haInitialize
  13. or haTerminate unless specifically required for the example. For
  14. simplicity, they also lack most error checking that good
  15. programming technique requires. Please add return code tests and
  16. have your program take appropriate action.
  17.  
  18. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
  19. /*
  20.  * Capture data to disk.
  21.  *This program segment:
  22.  *    - Waits for a prompt string ("Press Enter to begin...")
  23.  *      from the remote system
  24.  *    - Begins capturing all incoming data -- one line at a time
  25.  *      as the carriage return character is received
  26.  *    - Appends incoming data to the end of the session's 
  27.  *      default capture file if the file already exists
  28.  *    - Stops capturing data when an end string appears ("End of
  29.  *      Data") */
  30.    ReturnCode = haWaitForPrompt(ScriptHandle, 1, "Press Enter to begin...", 300, 60000)
  31.    ReturnCode = haCaptureBegin(ScriptHandle, "HA_C_LINES", "TRUE")
  32.    ReturnCode = haWaitForString(ScriptHandle, 1, "End of Data", 100000)
  33.    ReturnCode = haCaptureControl(ScriptHandle, "HA_C_END")
  34.  
  35. /**************************************************************/
  36.  
  37. /*
  38.  * Capture data to printer.
  39.  *   This program segment:
  40.  *   - Waits for a prompt string ("Turn printer on and press Enter to begin...")
  41.  *     from the remote system
  42.  *   - Begins capturing all incoming data -- one line at a time as the
  43.  *     cursor moves off the line.
  44.  *   - Releases each page to the printer as it fills.
  45.  *   - Stops capturing data when an end string appears ("End of Data")
  46.  */ 
  47.    ReturnCode = haWaitForPrompt(ScriptHandle, 1, "Turn printer on and press Enter to begin...", 300, 60000)
  48.    ReturnCode = haCaptureToPrinterBegin(ScriptHandle, "HA_CP_LINES", "HA_CP_PAGE")
  49.    ReturnCode = haWaitForString(ScriptHandle, 1, "End of Data", 100000)
  50.    ReturnCode = haCaptureToPrinterControl(ScriptHandle, "HA_CP_END")
  51.  
  52. /**************************************************************/
  53.  
  54. /*
  55.  * Close an open session.
  56.  */
  57.  
  58.    ReturnCode = haCloseSession(ScriptHandle)
  59.  
  60. /**************************************************************/
  61.  
  62. /*
  63.  * Dial a remote system from within a script.
  64.  * This program segment:
  65.  *    - Displays a message box to ask if user wants to change the phone number.
  66.  *    - If yes, it displays another message box to get the new phone number.
  67.  *    - Connects and dials using the new phone number or uses a standard
  68.  *      session connect if the user doesn't want to change the phone number.
  69.  */
  70.  
  71.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Change Phone Number?", 0, , "HA_MB_YN")
  72.    IF ReturnCode = 1 THEN
  73.       DO
  74.       SubReturnCode = haMessageBox(ScriptHandle, "HAOS2 Query:", "Enter Phone Number:", 128, "PNumber", "HA_MB_OK")
  75.       SubReturnCode = haConnectAndDial(ScriptHandle, "HA_CNCT_STANDARD", PNumber)
  76.       END
  77.    IF ReturnCode = 0 THEN
  78.       SubReturnCode = haConnectSession(ScriptHandle, "HA_CNCT_STANDARD")
  79.  
  80. /**************************************************************/
  81.  
  82. /*
  83.  * Connect a session without dialing and transfer all typed characters to the
  84.  * modem. This is often referred to as "Terminal Mode".
  85.  *
  86.  * This program segment:
  87.  *    - Tells HyperACCESS not to call the remote system on connection.
  88.  *  This function (haSkipConnection) is required in case the program
  89.  *      is run as a preconnection program. Otherwise it is ignored.
  90.  *      - Checks the current connection status, and if already connected 
  91.  *        releases resources and returns control to HyperACCESS.
  92.  *      - If not connected, request HyperACCESS to connect the session
  93.  *        (without dialing). 
  94.  *      - Don't wait for connection because there won't be one until the 
  95.  *        user types commands at keyboard.
  96.  *      - Release resources and return control to HyperACCESS.
  97.  */
  98.  
  99.    ReturnCode = haSkipConnection(ScriptHandle)
  100.  
  101.    Status = haGetConnectionStatus(ScriptHandle)
  102.    IF haGetConstantString("haGetConnectionStatus", Status) = "HA_CONNECTED" THEN
  103.       DO
  104.       ReturnCode = haTerminate(ScriptHandle)
  105.       END
  106.  
  107.    ReturnCode = haConnectSession(ScriptHandle, "HA_CNCT_DO_NOT_DIAL")
  108.    ReturnCode = haTerminate(ScriptHandle)
  109.  
  110. /**************************************************************/
  111.  
  112. /*
  113.  * Disconnect from a remote system.
  114.  */
  115.  
  116.    ReturnCode = haDisconnectSession(ScriptHandle)
  117.  
  118. /**************************************************************/
  119.  
  120. /*
  121.  * Gather and display port information.
  122.  *   This program segment:
  123.  *      - Gets the port type, name, and device name.
  124.  *      - Displays the resulting string in a message box.
  125.  */
  126.  
  127.    ReturnCode = haGetPortPrefs(ScriptHandle, 128, "PType", 128, "PName", 128, "DName")
  128.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS",PType||PName||DName, 0, , "HA_MB_OK")
  129.  
  130. /*
  131.  * The function "haGetPortType" also gets port type, but none of the other 
  132.  * information:
  133.  */
  134.  
  135.    ReturnCode = haGetPortType(ScriptHandle, 128, "PType")
  136.  
  137. /**************************************************************/
  138.  
  139. /*
  140.  * Get the capture filename from the current session and let the user change it.
  141.  *   This program segment:
  142.  *      - Gets the capture filename.
  143.  *      - Displays the filename in a message box and asks if user wants to 
  144.  *        change the capture file.
  145.  *      - If the user selects the Yes response, another message box request
  146.  *        a new filename.
  147.  *      - If the user enters a new filename, it's saved as the session 
  148.  *        capture file.
  149.  */
  150.  
  151.    ReturnCode = haGetCaptureFileName(ScriptHandle, 128, "FName")
  152.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Change name to: "FName, 0, , "HA_MB_YN")
  153.    IF ReturnCode >= 0 THEN
  154.       DO
  155.       SubReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Enter new Capture File:", 128, "FName", "HA_MB_OK")
  156.       SubReturnCode =  haSetCaptureFileName(ScriptHandle, FName)
  157.       END
  158.       
  159. /**************************************************************/
  160.  
  161. /*
  162.  * Check the status of the current connection. If offline, make connection.
  163.  *   This program segment:
  164.  *      - Checks connection status.
  165.  *      - If disconnected, request HyperACCESS to perform a standard connection
  166.  *        sequence.
  167.  *      - Wait for connection.
  168.  *      - If connected on entry or connected successfully display "Online" messge.
  169.  *      - If connection fails for any reason, display "Connection Failed" message. 
  170.  */
  171.  
  172.    Status = haGetConnectionStatus(ScriptHandle)
  173.    IF haGetConstantString('haGetConnectionStatus', Status) = "HA_DISCONNECTED" THEN
  174.       DO
  175.       ReturnCode = haConnectSession(ScriptHandle, "HA_CNCT_STANDARD")
  176.       IF SubReturnCode = 0 THEN
  177.          ReturnCode = haWaitForConnection(ScriptHandle, "HA_CONNECTED", 60000)
  178.       END
  179.    IF ReturnCode = 0 THEN
  180.       DO
  181.       haMessageBox(ScriptHandle, "HyperACCESS", "Online!", 0, , "HA_MB_OK")
  182.       END
  183.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Connection Failed!", 0, , "HA_MB_OK")
  184.  
  185. /**************************************************************/
  186.  
  187. /*
  188.  * Change the screen color regardless of terminal emulator in use.
  189.  *   This program segment:
  190.  *      - Gets the current terminal emulator.
  191.  *      - Change the terminal emulator to ANSI so that local commands can
  192.  *        change screen color.
  193.  *      - Type local text to change screen color to blue letters on white 
  194.  *        background (see DOS help for ANSI.SYS).
  195.  *      - Sets the terminal emulator back to its original type.
  196.  */
  197.  
  198.    ReturnCode = haGetEmulator(ScriptHandle, 128, "Emulator")
  199.    ReturnCode = haSetEmulator(ScriptHandle, "ANSI")
  200.    ReturnCode = haTypeLocalText(ScriptHandle, "1B"x||"[37;44;1m")
  201.    ReturnCode = haSetEmulator(ScriptHandle, Emulator)
  202.  
  203. /**************************************************************/
  204.  
  205. /*
  206.  * Let the user change the dialing prefix if necessary.
  207.  *   This program segment:
  208.  *      - Gets the first dialing prefix for the current session.
  209.  *      - Displays the current prefix in a message box and asks for Yes/No 
  210.  *        response to question.
  211.  *      - If response is Yes, asks user for new prefix.
  212.  *      - Sets new prefix (for all sessions).
  213.  */
  214.  
  215.    ReturnCode = haGetDialingPrefix(ScriptHandle, 1, 128, "PNumber")
  216.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Is this string correct: "PNumber, 0, , "HA_MB_YN")
  217.    IF ReturnCode = 0 THEN
  218.       DO
  219.       ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Enter new prefix:", 128, "PNumber", "HA_MB_OK")
  220.       ReturnCode = haSetDialingPrefix(ScriptHandle, 1, PNumber)
  221.       END
  222.  
  223. /**************************************************************/
  224.  
  225. /*
  226.  * Prompt remote user for data, and respond.
  227.  *   This program segment:
  228.  *      - Sends text to remote system requesting input from remote user.
  229.  *      - Gets input from communications port, but lets HyperACCESS process
  230.  *        any backspace characters. Waits 100 sec. for first character.
  231.  *        Waits 30 sec. between characters.
  232.  *      - If remote user responds, formats response and types message to 
  233.  *        remote user.
  234.  */
  235.  
  236.    ReturnCode = haTypeText(ScriptHandle, 0, "Enter First Name: ")
  237.    ReturnCode = haGetInput(ScriptHandle, "HA_GI_BACKSPACE", -1, 100000, 30000, "FName")
  238.    IF ReturnCode >= 0 THEN
  239.       DO
  240.       ReturnCode = haTypeText(ScriptHandle, 0, "Welcome to the system," FName)
  241.       END
  242.  
  243. /**************************************************************/
  244.  
  245. /*
  246.  * Get the log filename and let the user change files if desired.
  247.  *   This program segment:
  248.  *      - Gets the log filename for the current session.
  249.  *      - Displays log filename in a message box and asks for Yes/No 
  250.  *        response to question.
  251.  *      - If response is Yes, asks user for new filename and sets new log file.
  252.  */
  253.  
  254.    ReturnCode =  haGetLogFileName(ScriptHandle, 128, "LogName")
  255.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Change Log Filename:" LogName, 0, , "HA_MB_YN")
  256.    IF ReturnCode = 0 THEN
  257.       DO
  258.       ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Enter new Log File:", 128, "LogName", "HA_MB_OK")
  259.       ReturnCode =  haSetLogFileName(ScriptHandle, LogName)
  260.       END
  261.  
  262. /**************************************************************/
  263.  
  264. /*
  265.  * Open the first session in the Phonebook and connect to it
  266.  *   This program segment:
  267.  *      - Gets the filename of the first Phonebook entry
  268.  *      - Requests HyperACCESS to open and connect to the session.
  269.  *        (It doesn't wait for connection to complete.)
  270.  */
  271.  
  272.    ReturnCode = haGetPhonebookEntry(ScriptHandle, 1, 128, "FName")
  273.    ReternCode = haOpenSession(ScriptHandle, FName)
  274.    ReturnCode = haConnectSession(ScriptHandle, "HA_CNCT_STANDARD")
  275.  
  276. /**************************************************************/
  277.  
  278. /*
  279.  * Get runtime values for  NAME, USERID, and PASSWORD. Then use those values.
  280.  *   This program segment:
  281.  *      - Gets runtime values if they exist. The TRUE parameter indicates
  282.  *        that HyperACCESS should automatically prompt for a value if one 
  283.  *        isn't already stored.
  284.  *      - Use the UserId and password as part of a login sequence with a 
  285.  *        remote system.
  286.  */
  287.    
  288.    ReturnCode = haGetRuntimeValue(ScriptHandle, "HA_RV_USERNAME", "TRUE", 128, "UName")
  289.    ReturnCode = haGetRuntimeValue(ScriptHandle, "HA_RV_USERID", "TRUE", 128, "UID")
  290.    ReturnCode = haGetRuntimeValue(ScriptHandle, "HA_RV_PASSWORD", "TRUE", 128, "PWord")
  291.  
  292.    /* Assume a connection has been made for this example to talk to. */
  293.    ReturnCode = haWaitForPrompt(ScriptHandle, 1, "LOGON ID:", 1000, 60000)
  294.    ReturnCode = haTypeText(ScriptHandle, 0, UID)
  295.    ReturnCode = haWaitForPrompt(ScriptHandle, 1, "Password:", 1000, 60000)
  296.    ReturnCode = haTypeText(ScriptHandle, 0, PWord)
  297.  
  298. /**************************************************************/
  299.  
  300. /*
  301.  * Get the filename of the currently selected session. If more than one is
  302.  * selected, gets the first session filename
  303.  */
  304.  
  305.    ReturnCode = haGetSelectedPhonebookEntry(ScriptHandle, 1, 128, "FName")
  306.  
  307. /**************************************************************/
  308.  
  309. /*
  310.  * Get text from specific screen positions.
  311.  *   This program segment:
  312.  *      - Requests 10 characters starting at screen position 0,35
  313.  *        where 0 is vertical position (from top), 
  314.  *            35 is horizontal position (from left).
  315.  */
  316.  
  317.    ReturnCode = haGetTextFromScreen(ScriptHandle, 0, 35, 10, "ScrText")
  318.  
  319. /**************************************************************/
  320.  
  321. /*
  322.  * Gets HyperACCESS version number, and display it.
  323.  *   This program segment:
  324.  *      - Gets HyperACCESS version number
  325.  *      - Displays log filename in a message box that only accepts on OK 
  326.  *        response.
  327.  */
  328.  
  329.    ReturnCode = haGetVersion(ScriptHandle, 128, "Vers")
  330.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Version: "Vers, 0, , "HA_MB_OK")
  331.  
  332. /**************************************************************/
  333. /**************************************************************/
  334.  
  335. /* The following program segments illustrate how to use API functions to
  336.    manage file transfers. They show how to set directories for send and receive, 
  337.    change transfer protocol, create a list of files to send, and add files to 
  338.    the list. */
  339.  
  340. /**************************************************************/
  341. /**************************************************************/
  342.  
  343. /*
  344.  * Get (and set) directory path to receive files.
  345.  *   This program segment:
  346.  *      - Gets default receive directory path.
  347.  *      - Use a message box to ask if the user wants to change the default path.
  348.  *      - If the user responds Yes, request a new directory path using a message box.
  349.  *      - Sets the new directory as the default.
  350.  */
  351.  
  352.    ReturnCode = haGetXferDirectory(ScriptHandle, "HA_XFER_RECV", 128, "DName")
  353.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Change Receive Directory Path?", 0, , "HA_MB_YN")
  354.    IF ReturnCode = 1 THEN
  355.       DO
  356.          SubReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Enter Receive Directory:", 128, "DName", "HA_MB_OK")
  357.          SubReturnCode = haSetXferDirectory(ScriptHandle, "HA_XFER_RECV", DName)
  358.       END
  359.  
  360. /**************************************************************/
  361.  
  362. /*
  363.  * Let the user set default transfer protocols.
  364.  *   This program segment:
  365.  *      - Switches to the Terminal Panel.
  366.  *      - Uses the Properties/Transfer Protocols... menu item to display
  367.  *        the Transfer Protocols dialog so the user can select new protocols.
  368.  */
  369.  
  370.    ReturnCode = haMenuString(ScriptHandle, "W0")
  371.    ReturnCode = haMenuString(ScriptHandle, "PT")
  372.  
  373. /**************************************************************/
  374.  
  375. /*
  376.  * Set the default receive protocol.
  377.  *   This program segment:
  378.  *      - Sets the default receive protocol to HyperProtocol.
  379.  */
  380.  
  381.    ReturnCode = haSetXferProtocol(ScriptHandle, "HA_XFER_RECV", "HA_HYPERP")
  382.  
  383. /**************************************************************/
  384.  
  385. /*
  386.  * Check current general transfer parameters, and change value. 
  387.  *   This program segment:
  388.  *      - Gets the current transfer parameters.
  389.  *      - Sets transfer parameter to overwrite an existing file if parameters
  390.  *        were set previously to append to an existing file.
  391.  */
  392.  
  393.    XParms = haGetXferParameters(ScriptHandle)
  394.    IF BITAND(XParms,haDecodeString("XF_DN_APPEND")) <> 0 THEN
  395.       DO
  396.       XParms = BITXOR(XParms,haGetConstantValue("XF_DN_MASK"))
  397.       XParms = BITOR(XParms,haGetConstantValue("XF_DN_OVERWRT"))
  398.       ReturnCode = haSetXferParameters(ScriptHandle, XParms)
  399.       END                                 
  400.  
  401. /**************************************************************/
  402.  
  403. /*
  404.  * Receive a specific file. 
  405.  *   This program segment:
  406.  *      - Uses the default receive protocol and directory.
  407.  *      - Starts to receive a particular file assuming the protocol supports
  408.  *        filename transfers. The TRUE parameter indicates that HyperACCESS
  409.  *        shouldn't return to the function until the transfer is complete.
  410.  */
  411.  
  412.    ReturnCode = haXferReceive(ScriptHandle, "MYFILE.TXT", "TRUE")
  413.  
  414. /**************************************************************/
  415.  
  416. /*
  417.  * Send a specific file.
  418.  *   This program segment:
  419.  *      - Sends a particular file using an absolute path.
  420.  *      - The FALSE parameter indicates that HyperACCESS
  421.  *        should return to the function as soon as the transfer starts.
  422.  *      - Minimizes the HyperACCESS application window.
  423.  *      - Allow up to 1 hour for transfer to complete. 
  424.  *      - If timeout, display an error message.
  425.  */
  426.  
  427.       ReturnCode = haXferSend(ScriptHandle, "C:\HAOS2\DOOM.ZIP", "FALSE")
  428.       ReturnCode = haSizeHyperACCESS(ScriptHandle, "HA_S_MIN")
  429.       ReturnCode = haWaitForXfer(ScriptHandle, 3600000)
  430.       IF haGetErrorString(ReturnCode) <> "HA_ERR_OK" THEN
  431.          DO
  432.          ReturnCode = haMessageBox(ScriptHandle, "Transfer Error", "Transfer timed out.", 0, , "HA_MB_OK")
  433.          END
  434.  
  435. /**************************************************************/
  436.  
  437. /*
  438.  * Send a text file as if it were typed.
  439.  *   This program segment:
  440.  *      - Sends a text file as typed data.
  441.  */
  442.  
  443.    ReturnCode = haTextSend(ScriptHandle, "C:\HAOS2\LETTER.TXT")
  444.  
  445. /**************************************************************/
  446.  
  447. /*
  448.  * Send multiple files specified by the user.
  449.  *   This program segment:
  450.  *      - Uses a message box to ask if the user has file(s) to send.
  451.  *      - Loops until user finished adding.
  452.  *      - Sends list of files.
  453.  */
  454.  
  455.    ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Do you want to send files" , 0 , , "HA_MB_YN")
  456.    IF ReturnCode = 1 THEN
  457.       DO
  458.          DO While ReturnCode = 1
  459.          ReturnCode = haMessageBox(ScriptHandle, "HyperACCESS", "Enter a file to send:" , 128, "FName", "HA_MB_OK")
  460.          ReturnCode = haXferAddToSendList(ScriptHandle, FName)
  461.          END
  462.       ReturnCode = haXferSendFromList(ScriptHandle, "TRUE")
  463.    END
  464.  
  465. /**************************************************************/
  466.  
  467. /*
  468.  * Check the first file in the list.
  469.  *   This program segment:
  470.  *      - Gets the first file in the send list (index starts at 0)
  471.  *      - Uses a message box to display the filename and ask if OK.
  472.  */
  473.  
  474.    ReturnCode = haGetXferSendList(ScriptHandle, 0, 128, "FName")
  475.    ReturnCode = haMessageBox(ScriptHandle, "First file to send:", FName, 0, , "HA_MB_OK")
  476.  
  477. /**************************************************************/
  478.  
  479. /*
  480.  * Hide received characters.
  481.  *   This program segment:
  482.  *      - Hides received characters.
  483.  *      - Waits for a carriage return (or 30 seconds).
  484.  *      - Enables display of received characters after one line
  485.  */
  486.  
  487.    ReturnCode = haSetLocalDisplay(ScriptHandle, "FALSE")
  488.    ReturnCode = haWaitForLines(ScriptHandle, 1, 30000)
  489.    ReturnCode = haSetLocalDisplay(ScriptHandle, "TRUE")
  490.  
  491. /**************************************************************/
  492.  
  493. /* Changes a dialing prefix to a new value. 
  494.    This program segment:
  495.       - Changes the first dialing prefix (for all sessions) to "1-313" */
  496.  
  497.    ReturnCode = haSetDialingPrefix(ScriptHandle, 1, "1-313")
  498.  
  499. /**************************************************************/
  500.  
  501. /*
  502.  * Select dialing prefix.
  503.  *   This program segment:
  504.  *      - Selects the first dialing prefix as the one to use 
  505.  *        for this session
  506.  */
  507.  
  508.    ReturnCode = haSelectDialingPrefix(ScriptHandle, 1)
  509.  
  510. /**************************************************************/
  511.  
  512. /*
  513.  * Turn off automatic download feature of Zmodem and HyperProtocol.
  514.  */
  515.  
  516.    ReturnCode = haSetAdlOverride(ScriptHandle, "TRUE")
  517.  
  518. /**************************************************************/
  519.  
  520. /*
  521.  * Change the baud rate of the current session.
  522.  *      - This program segment sets the baud rate to 19,200.
  523.  */
  524.  
  525.    ReturnCode = haSetBaudRate(ScriptHandle, 19200)
  526.  
  527. /**************************************************************/
  528.  
  529. /* Set character echo for half duplex operation.
  530.    This program segment:
  531.       - Disables echo of characters received.
  532.       - Enables echo of characters sent so they display locally. */
  533.  
  534.    ReturnCode = haSetEcho(ScriptHandle, "FALSE")
  535.    ReturnCode = haSetLocalEcho(ScriptHandle, "TRUE")
  536.  
  537. /**************************************************************/
  538.  
  539. /*
  540.  * Set connect script for the current session.
  541.  */
  542.  
  543.    ReturnCode = haSetLogonTask(ScriptHandle, "C:\HAOS2\LOGON.CMD")
  544.  
  545. /**************************************************************/
  546.  
  547. /*
  548.  * Dismiss message boxes after fixed period of time. This lets a user respond
  549.  * if present, or continues with default actions if no user response received
  550.  * in fixed time interval (10 seconds, in example).
  551.  */
  552.  
  553.    ReturnCode = haSetMessageTimer(ScriptHandle, 10)
  554.  
  555. /**************************************************************/
  556.  
  557. /*
  558.  * Change communications parameters.
  559.  *   This program segment:
  560.  *      - Sets the port mode to 8 bit, no parity, 1 stop bit.
  561.  *      - Sets the port name to "COM1".
  562.  *      - Sets the port type to "Standard COM Port".
  563.  */
  564.  
  565.    PMode = 0
  566.    PMode = BITOR(PMode, haGetConstantValue("HA_M_8_BITS"))
  567.    PMode = BITOR(PMode, haGetConstantValue("HA_M_N_PRTY"))
  568.    PMode = BITOR(PMode, haGetConstantValue("HA_M_1_STOP"))
  569.    ReturnCode = haSetPortMode(ScriptHandle, PMode)
  570.    ReturnCode = haSetPortName(ScriptHandle, "COM1")
  571.    ReturnCode = haSetPortType(ScriptHandle, "STANDARD COM PORT")
  572.  
  573. /**************************************************************/
  574.  
  575. /*
  576.  * Change communications parameters and modem.
  577.  *   This program segement:
  578.  *      - Uses one function call to set port name, port type, and modem
  579.  */
  580.  
  581.    ReturnCode = haSetPortPrefs(ScriptHandle, "STANDARD COM PORT", "COM1", "Amstrad Quad")
  582.  
  583. /**************************************************************/
  584.  
  585. /*
  586.  * Change dialing type to PULSE.
  587.  */
  588.  
  589.    ReturnCode = haSetPulseTone(ScriptHandle, "HA_PT_PULSE")
  590.  
  591. /**************************************************************/
  592.  
  593. /*
  594.  * Set the number of rings to answer the phone, and put modem in answer mode. 
  595.  *   This program segment:
  596.  *      - Sets the number of rings before answer to 3.
  597.  *      - Connects the session to its port in answer mode.
  598.  */
  599.  
  600.    ReturnCode = haSetRingsForAnswer(ScriptHandle, 3)
  601.    ReturnCode = haConnectSession(ScriptHandle, "HA_CNCT_ANSWER_MODE")
  602.  
  603. /**************************************************************/
  604.  
  605. /*
  606.  * Set HyperACCESS window sizes.
  607.  *   This program segment:
  608.  *      - Maximizes the HyperACCESS application window.
  609.  *      - Sets the session window to its previous size.
  610.  */
  611.  
  612.    ReturnCode = haSizeHyperACCESS(ScriptHandle, "HA_S_MAX")
  613.    ReturnCode = haSizeSession(ScriptHandle, "HA_S_RSTR")
  614.  
  615. /**************************************************************/
  616.  
  617. /*
  618.  * Pause execution of the script. haSleep doesn't block other tasks from
  619.  * getting CPU time, and lets HyperACCESS continue to send and receive data. 
  620.  *   This program segment:
  621.  *      - Pauses for 10 seconds.
  622.  */
  623.  
  624.    ReturnCode = haSleep(ScriptHandle, 10000)
  625.  
  626. /**************************************************************/
  627.  
  628. /*
  629.  * Wait for activity from remote system.
  630.  *   This program segment:
  631.  *      - Waits up to 100 seconds for HyperACCESS to receive a character
  632.  *        from the remote system.
  633.  */
  634.  
  635.    ReturnCode = haWaitForActivity(ScriptHandle, 100000)
  636.  
  637. /**************************************************************/
  638.  
  639. /*
  640.  * Wait for no activity from remote system.
  641.  *   This program segment:
  642.  *      - Waits up to 100 seconds for HyperACCESS to stop receiving 
  643.  *        characters from the remote system. It defines a lull as 5 seconds
  644.  *        without activity.
  645.  */
  646.  
  647.    ReturnCode = haWaitForLull(ScriptHandle, 5000, 100000)
  648.  
  649. /**************************************************************/
  650.