Knowledge Base Ask Cody Resources



 
Can I do screen scraping with IntelliTerm?
Intelliterm provides an API that allows you to automate various
emulation-related tasks, including screen scraping.
For browsing through 3270 fields there is the Fields collection in the Host
object, each Field object containing properties like Text, Length, Position,
IsProtected, etc. To access the Intelliterm API you can either use the
built-in macro mechanism, which includes a Basic-clone language, or create
and manage Intelliterm sessions externaly through OLE Automation with any
development environment that supports OLE automation.
Here are some examples of how macros can be used. A macro like this:

Sub Main
For i=1 To CurrentHost.Fields.Count
MsgBox CStr(CurrentHost.Fields(i).Text)
Next
End Sub

will browse through all 3270 fields on the current screen and show the
contents of each field in a message box. To try this macro, open
Intelliterm, connect to a 3270 host, go to Macro->Edit and copy the macro
text into Macro Editor window (note that the Editor will prefill the text
with Sub Main/End Sub statements, so be sure not to copy them twice). Press
F5 in the Macro Editor to run the macro.

You can also save your macro in a file, (File->Save as in Macro Editor)
which will allow you to assign macros to keystrokes (so that every time a
key is pressed, your macro would be executed). To do this, go to
Options->Terminal Settings->Keyboard mapping (Intelliterm's main window). In
the Keyboard Mapping dialog that will appear, select a key you want to map
your macro to, then select "Macro" in the "Select function type" select box and
browse to the file with the macro. After that, click set to do the assingment,
and then click Save to save the new setting in a profile (so that the
setting will be remembered in future sessions)

Your real macros of course can be more complex than the one shown above. For
example, a macro like this:

Sub Main
Dim smtp As Object
Set smtp=CreateObject("DCVSMTP.DCVSMTPCtrl.1")
For i=1 To CurrentHost.Fields.Count

smtp.EasySend("10.0.0.10","john@distinct.com","jack@distinct.com","","","fie
ld #"+CStr(i),CurrentHost.Fields(i).Text,"","c:\temp")
Next
End Sub

will send the contents of each field by email (actually you'll need to have
Distinct Mail Objects installed to make it work), or you can store the
contents in a file by a macro like

Sub Main
Dim smtp As Object
Dim f as Object
Set fs=CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile("c:\temp\test.txt",8,true)
For i=1 To CurrentHost.Fields.Count
f.WriteLine("Field #"+CStr(i)+":"+CurrentHost.Fields(i).Text)
Next
f.Close()
End Sub





12/26/2024   Legal notices | PRIVACY Policy |