28.3 Creating a Macro

Create a macro that gets the text from the screen and displays it in a message box. For information about how to create a macro, see Create a Macro with the VBA Editor.

Continue with Configuring the Emulator Type of Terminal Launcher.

Samples

Printing the Screen Text

The following is a sample VB script of a macro to capture the screen text:

Sub CopyTextMacro()
    'Create a variable to hold the text
    Dim screenText As String
      
    'Get text from the screen starting at screen row 1, column 1, and 30 characters long
     screenText = ThisIbmScreen.GetText(1, 1, 30)
      
    'Display the text in a message box
    MsgBox (screenText )
End Sub

The following is a valid response from the Reflection application and the same response is shown in the console of IBM Simulator 3230 by using Trace Player:

Saving the Entire Screen as Text

The following sample gets all text displayed on a screen and saves that to a text file:

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

For information about how to run this script in Visual Basic Editor, see Save Screens as Text.

Opening a Session Dynamically

You can open or close sessions dynamically. For information about how to open a terminal session from another session that is running in the Reflection workspace, see Dynamically Open a Session.

Save the session and create a working SecureLogin script for the Terminal Emulator type that prints MessageBox to evaluate the interactions of Terminal Launcher. If launched from Terminal Launcher 32, launch the same.