This sample gets all of the text on a screen before the screen data is transmitted and saves it to a text file.
To run this sample
- In an Ibm terminal session, open the Visual Basic Editor, copy the code into the ThisIbmScreen code window.
- Save the session and then reopen it.
- Enter some data on a terminal session screen and then open the log file to check the results. (The .log file has the same name as your session document file and is in the same folder as that file.)
Save screens as text |
Copy Code
|
Private Function IbmScreen_BeforeSendControlKey(ByVal sender As Variant, key As Long) As Boolean
Dim screenRows As Integer
Dim screenColumns As Integer
Dim fnum As Integer
Dim screenShot As String
screenRows = ThisIbmScreen.rows
screenColumns = ThisIbmScreen.columns
'Get all the text on the screen
screenShot = ThisIbmScreen.GetTextEx(1, 1, screenRows, screenColumns, GetTextArea_Block, _
GetTextWrap_Off, GetTextAttr_Any, GetTextFlags_CRLF)
'Add a line to separate each screen
screenShot = screenShot & "................................................................................"
'Open a file and append the screenshot to the file
path = ThisIbmTerminal.SessionFilePath & ".log"
fnum = FreeFile()
Open path For Append As fnum
Print #fnum, screenShot
Close #fnum
IbmScreen_BeforeSendControlKey = True
End Function
|
Concepts
This sample handles the BeforeSendControlKey event to append all the text on the screen to a log file before leaving the screen. The GetTextEx method is used to capture a region of a screen and in this case, arguments are passed to capture the whole screen from position 1,1 to the maximum rows and columns.
A line is added to the data to separate the screens before the data is appended to a file.
For more about ways you can use events, see Using Reflection Events.
This sample gets all of the data in display memory when a session is closed and saves it to a text file.
To run this sample
- In an Open Systems terminal session, open the Visual Basic Editor and copy this code into the ThisTerminal code window.
- Save the session and then reopen it.
- Enter some data on a terminal session screen and open the log file to check the results. (The .log file has the same name as your session document file and is in the same folder as that file.)
Save screens as text |
Copy Code
|
Private Function Terminal_Closing(ByVal sender As Variant) As Boolean
Dim screenText As String, topRow As String
Dim maxRow As Long, maxCol As Long, fnum As Integer
maxRow = ThisScreen.DisplayRows
maxCol = ThisScreen.DisplayColumns
topRow = ThisScreen.DisplayMemoryTopRow
'Get all the text, starting at the top row of display memory and the first column and ending at the
'maximum row and column
screenText = ThisScreen.GetText3(topRow, 1, maxRow, maxCol, RegionOption_Wrapped, _
TextTranslationOption_NoTranslation)
'Open a file and append the screen text
path = ThisTerminal.SessionFilePath & ".log"
fnum = FreeFile()
Open path For Append As fnum
Print #fnum, screenText
Close #fnum
Terminal_Closing = True
End Function
|
Concepts
This sample handles the Closing event to append all the text in display memory to a log file before the session is closed. The GetText3 method is used to capture a region of text and in this case, arguments are passed to capture the whole display memory from the top row and the first column to the maximum row and column.
For more about how you can use events, see Using Reflection Events.