HowTos > Save Screens as Text |
This sample saves the text displayed in a terminal session to a text file.
![]() |
This article contains tabbed content that is specific to each terminal type. Be sure the tab for your terminal type is selected. |
This sample gets all of the text on a screen before the screen data is transmitted and saves it to a text 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 |
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 positon 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 InfoConnect Events.
This sample gets all of the data in display memory when a session is closed and saves it to a text 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 |
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 InfoConnect Events.