IBMlogo
IBM eNetwork Communications Server for Windows NT, Version 6.01 Host Publisher Feature
[Next|Previous|Contents]

Host Publisher Hints and Tips

Sample 2

This is the second sample that uses the Host Simulator. The user specifies the userid and password on a Web form; the integration object invokes a host application and collects data from it; and an error macro detects and recovers from a disconnected state.

This sample is much more complicated than the previous one. Please work through that one if you have not done so already, and ensure it is working before attempting this one.

Somewhat less detailed instructions will be given for this sample so it doesn't get too lengthy.

There are two host simulator files for this sample. sample2a.smp shows normal operation, while sample2b.smp is a host session in which the previous session was not properly logged off, so the logon appears in a reconnected state.

Follow these steps:

  1. Create a new WBL by selecting the menu item File/New/Library.
  2. Create a new book (File/New/Book).
  3. Create the Web page where the user will provide a userid and password as follows:
    1. Select menu item File/New/Page
    2. Right-click on the new Web page, select Rename page, and name it Page1.
    3. Enter the following text into the Web page:
      <form action="page2.dml" method="get">
      Enter a userid and password and press submit:<br>
      Userid <input name="userid" size=8><br>
      Password <input type=password name="password" size=8><br>
      <input type=submit value="Submit">
      <input type=reset value="Reset">
      </form>
      
    This enables the user to provide a userid and password and pass them to the second Web page, which provides them to the integration object.
  4. Create the integration object.
    1. Select menu item File/New/Integration Object.
    2. Set the type of the integration object to Host Access.
    3. Click Configuration and specify Host Server localhost and port 2300.
    4. Ensure that you are on the Macro page in the Integrator and that the Connect macro is selected.
    5. Click Attach and select the macro file sample1_logon.hmf to use the same connect macro as the first sample.
    6. Modify the connect macro to use the user-provided userid and password as follows:
      1. Click Edit.
      2. In the macro editing window, find the line
        ps.SendKeys("langw[tab]ab1c2d[enter]");
        
        This macro command sends the userid and password to the host.
      3. Before the ps.SendKeys line, insert these two lines:
        prompt(20,16,8,":userid","",true);
        prompt(21,16,8,":password","",true,"*");
        
        These lines enter the userid and password provided by the user at screen positions 20,16 and 21,16. These are row,column positions. The previous line "screenDesc.AddCursorPos(20,16)" told us the cursor was at 20,16 when the host was prompting for the userid, and we know that the password field is one row lower. We could also have identified these screen positions from the terminal window. The row and column cursor position is shown in the terminal window's lower right corner.
      4. Remove "langw[tab]ab1c2d" from the ps.SendKeys line, leaving only
        ps.SendKeys("[enter]");
        
      5. Press the window close button in the upper-right corner of the macro editing window to close the window.
      6. Save the modified macro using the name "sample2_logon.hmf".
      7. Click Attach and attach the macro file "sample2_logon.hmf" as the connect macro.
    7. Select the Disconnect macro.
    8. Click Attach and select the macro file sample1_logoff.hmf. This will use the same disconnect macro as the first sample.
    9. Click Show/Hide Terminal to show the terminal window. Move and resize it so you can still work with the Integration Object while the terminal window is visible.
    10. Start the Host Simulator and specify port 2300 and the input file sample2a.smp.
    11. Click Connect. You should see the MSG10 screen.
    12. Select the Connect macro and click Play. You should see the logon sequence.
    13. Select the Data loop macro and click Record. We will start the filelist application and then exit it. Note that the simulator session paged through the file list rather than exiting immediately, so things will look odd on the screen while we do this. We'll arrange to page through the file list later.
    14. In the terminal window, press Esc to send a Clear, then type filelist and hit Enter, then hit F3 to exit.
    15. Click Stop recording. Close the macro edit window, and save the macro as sample2_loop.hmf.
    16. Now define a screen to recognize the filelist application window.
      1. Return to just after logon by hitting Disconnect, stopping and restarting the Host Simulator, then hitting Connect and playing the Connect macro.
      2. Press Escape (Clear), type filelist and hit Enter to reach the filelist screen.
      3. In the Integrator, change to the Screens panel. Click Add... and define a new screen called "results". In the terminal window, use the mouse to mark the line of text across the column headings as the confirmation text, e.g. the row that begins with "Cmd Filename". This is a good way to identify the filelist application screen.
      4. Now define some data items. Change to the Items panel. Click Add... and enter the name filename. Now use the mouse to mark the entire Filename column in the terminal window. Repeat for filetype, date, and time.
      5. Since not all of the output of the filelist application is visible initially, define a screen macro to page through the output until the end.
        1. Use the Screens tab to return to the results screen definition
        2. Use the Macro tab on the smaller window to change from the Properties window to the screen Macro window.
        3. Click the Record button.
        4. In the terminal window, press F8 to page down.
        5. Click Stop Recording and save the macro as sample2_screen.hmf.
        6. In the Iterations section, change the setting to Until text visible, then mark the blank line that should be visible near the bottom of the filelist screen, near row 19, where there was file information on the first screen. This identifies the end of the file list.
        7. Change the Limit # of iterations to 30, just to be safe; you might use a higher number if you expect many files in your filelist.
      This completes the configuration of the integration object.
  5. Select the Web book in the upper left window.
  6. Select the menu item File/Page Wizard.
  7. Title the new page page2. (Recall that your first Web page was set up to send its form input to "page2.dml".) Click Next.
  8. Select Table Data Layout and click Next.
  9. Select Use an existing integration object and click Next.
  10. Select the integration object you just created and click Next.
  11. Select, in order, the items filename, filetype, date, and time. Click Next.
  12. Click Finish.
You are now ready to try it.
  1. Restart the Host Simulator.
  2. Select page1
  3. Click the Preview tab,
  4. Fill in a userid and password.
  5. Click Submit.

Error handling

We left out one feature, handling the case where the account gets disconnected without properly logging off. To see how this looks, set the Host Simulator to use input file sample2b.smp, connect, and logon. Instead of the usual Ready; prompt after logging in, you see RECONNECTED AT and the time. At this point, we can't be sure what state the account is in, and it is safest to just IPL before continuing.

We will recognize this state from our data loop macro by defining a screen with the RECONNECTED string as confirmation text, and then associating an error with that screen, also using the RECONNECTED string as confirmation text. The macro associated with the error will trigger the IPL.

(We could instead have used a screen macro associated with the screen itself, with an iteration count of 1.)

In order to recognize this screen, we need to start our data loop macro with a WaitForScreen that will succeed regardless of whether we're reconnected (since if it fails, Host Publisher will stop processing the integration object). The easiest way to do this is to identify text that appears in either case, shortly before the RECONNECTED or Ready; prompt. In our example, we look for the string FILES:.

  1. Select the data loop macro and click Edit.
  2. The first three lines should contain
    screenDesc.Clear();
    screenDesc.AddCursorPos(23,1);
    ps.WaitForScreen(screenDesc,10000);
    
    Change the second line to
    screenDesc.AddString("FILES:");
    
    so your macro starts with
    screenDesc.Clear();
    screenDesc.AddString("FILES:");
    ps.WaitForScreen(screenDesc,10000);
    
  3. Close the macro edit window and save the macro.
  4. Start the Host Simulator with sample2b.smp
  5. Connect and play the Connect macro. You should see the RECONNECTED string below the FILES: line.
  6. Go to the Screens window, define a screen called reconnected, and select the RECONNECTED string as the confirmation text.
  7. Define the error.
    1. Go to the Errors window and Add... an error.
    2. Give it an ID of 0 and long and short names of reconnected (these don't really matter).
    3. Select RECONNECTED as the confirmation text.
    4. Change to the Type panel.
    5. Set the severity to Recoverable
    6. Hit Record under the Macro section.
    7. In the terminal window, type IPL and hit Enter.
    8. Click Stop recording.
    9. Before saving the macro, add the following lines to the end so that the macro will wait until the IPL is complete:
      screenDesc.Clear();
      screenDesc.AddString("Ready;");
      ps.WaitForScreen(screenDesc,10000);
      
    10. Now save the macro as sample2_error.hmf.

You can try it just as before, except use sample2b.smp in the Host Simulator. Switch back and forth between sample2a.smp and sample2b.smp and verify that it works either way.

Note: This error handler does not function correctly if the integration object is scoped to client. The integration object does not logon, and the string "FILES:" does not appear when the data loop macro is executed the second time.


[Next|Previous|Contents]
IBM eNetwork Communications Server for Windows NT, Version 6.01 Host Publisher Feature