One of the more difficult
decisions to make is when to use EOS events vs. WaitForScreen.
The fundamental difference is blocking vs. speed. The WaitForScreen
event is very much arbitrary, while the EOS event is fired whenever
a screen is complete (typically when the keyboard is unlocked).
The best approach is always the EOS event, but for convenience
sake, it is ok to use the WaitForScreen with some arbitrary
waittime to accomplish your goals quickly and effectively, but
remember: Production Systems should always use the EOS.
To better use the EOS, you should utilize the Visual
3270 for Windows Emulator to count the number of EOS's that
actually fire. For example:

In the above example, we have recorded a script that types the
word "TSO" then presses enter. Notice that there are
TWO EOS events placing the cursor at position 320, and then
at 80. If you were to create a screen scraper application using
EOS Events you would have to count TWO EOS events and then you
would be on the right screen! If you used WaitForScreen, you
may be on the first EOS, start typing and then the protocol
would be broken as the emulator would not know what was happening.
As always, it is best to not place all your code in the OnEOS
event but rather utilize the DoEvents(VB) or ProcessMessages
(Delphi) or DispatchMessage (VC, or equivalent message flushing
technique). This is similar to the following code:
TNScraper.Connect
'this method works efficiently but doesn't
'check the screen contents. Developers
'shoudl consider using InStr() on the
'screen contents before moving forward.
Do
DoEvents
Loop Until (mEOS)
'At this point we should be at the first
'screen of the University of Florida's
'mainframe. We want to type LUIS
'at the command prompt
'Lets send the screen back to the web page
S = TNScraper.getScreen
myResponse.Write S
End Sub
Public
Sub TNScraper_OnEOS()
'This event is fired when a mainframe has
'sent a completed screen!
mEOS = True
End Sub
The above code was taken from the
"Articles on Creating Screen Scrapers for ActiveX."
and demonstrates the proper way to handle EOS event counting.
Notice you don't have to check for screen characters, cursorpositions,
etc. Just count the number of screens and your done!
OpenConnect is available for training and professional services
are available to get your project up and running. Call us today.
|