HowTos > Close Open Systems Sessions Gracefully |
You can prevent users from closing sessions until certain conditions are met.
This sample requires users to close an application before they terminate the session.
![]() |
This sample applies only to Open Systems terminals. |
To run this sample
Close session gracefully |
Copy Code
|
---|---|
'This sample allows closing of a session only after applications are closed and other conditions are met Private Function View_Closing(ByVal sender As Variant) As Boolean Dim screenAtLogoff As String 'Get all the displayed text before the view closes screenAtLogoff = ThisScreen.GetText2(1, 1, ThisScreen.DisplayRows, ThisScreen.DisplayColumns) 'Find out if the displayed text has the phrase that indicates the application is properly closed If InStr(1, screenAtLogoff, "connection has terminated") = 0 Then 'If exit is not found do not allow closing MsgBox "You can't close this session until you close the application" View_Closing = False Else View_Closing = True End If End Function |
This macro handles the Closing event to check for a user exit command. If it finds the command in the display memory, the event is set to true and the application closes. If not, the event is cancelled, and the user is not allowed to close the session.