Reflection Desktop VBA Guide
Attachmate.Reflection.Objects Library / Attachmate.Reflection.Objects.Productivity Library / ScreenHistory Object / ClearAllScreens Method
Example
In This Topic
    ClearAllScreens Method
    In This Topic
    Remove all screens from the Screen History list.
    Syntax
    expression.ClearAllScreens() 
    where expression is a variable that represents a ScreenHistory Object
    Example
    This example opens a screen history file and shows the last screen in the screen history. It clears all the screens before it opens the file.This example opens screen history after the session connects and saves it to a file after the session is disconnected. To run this example, copy this code to the ThisIbmTerminal code window.
    Sub OpenScreenHistoryAndShowLastScreen()
        Dim rcode As ReturnCode
        Dim lastScreen As Integer
        
        Dim path As String
        path = Environ("USERPROFILE") & "\Documents\Micro Focus\Reflection\test.rshx"
        
        Dim history As ScreenHistory
        Set history = ThisIbmTerminal.Productivity.ScreenHistory
     
        'Clear the screen history and wait for the screens to clear
        history.ClearAllScreens
        ThisIbmScreen.Wait (2000)
        
        'Open the screen history panel
        history.ScreenHistoryPanelVisible = True
        
        'Open a screen history file
        history.OpenScreenHistoryFile path, True
            
        'Show the last screen in the list
        lastScreen = history.Index
        history.ShowScreen lastScreen
        
    End Sub
    Private Sub IbmTerminal_AfterConnect(ByVal sender As Variant)
     
        'When a session connects, open Screen History
        ThisIbmTerminal.Productivity.ScreenHistory.ScreenHistoryPanelVisible = True
        
    End Sub
     
    Private Sub IbmTerminal_AfterDisconnect(ByVal sender As Variant)
        
        Dim rcode As ReturnCode
        Dim path As String
        Dim timeStamp As String
        
        'Get the current time, remove spaces, and replace invalid filename characters.
        timeStamp = Replace(Time, " ", "")
        timeStamp = Replace(timeStamp, ":", "-")
        
        'Set the file path and name.
        path = Environ("USERPROFILE") & "\Documents\Micro Focus\Reflection\" & timeStamp & "Screens" & ".rshx"
        
        'If a screen history exists, save it to a file.
        If ThisIbmTerminal.Productivity.ScreenHistory.Count > 0 Then
           
            rcode = ThisIbmTerminal.Productivity.ScreenHistory.SaveScreenHistoryFile(path, True)
            
            'Remove the screens from screen history
            ThisIbmTerminal.Productivity.ScreenHistory.ClearAllScreens
        
        End If
        
    End Sub
    See Also