Thanks calculus, You've come to the same conclusion that I have. Trouble is, as far as I can see, I am closing all files correctly. Here's some more details: 1. As far as I can tell, there are 2 macros which seem to tread on each others toes. When I run either of them, there is a chance that the other will refuse to start if I run it later in the same session. Both macros copy screen details and write them to a file. 2. Usually, closing the Extra session and restarting Extra cures the issue. This morning however, I had to reboot my PC to sort things out! 3. Below is the code for the smaller of the 2 macros - any suggestions? CODEGlobal g_HostSettleTime% Global g_szPassword$ Declare Sub SendScreen global lines Global Sess0 as object Global System as object Global Sessions as object
Sub Main() ' ****************************** ' * Get the main system object * ' ****************************** On Error Goto ErrProc Set System = CreateObject("EXTRA.System") ' Gets the system object If (System is Nothing) Then Msgbox "Could not create the EXTRA System object. Stopping macro playback." STOP End If Set Sessions = System.Sessions
If (Sessions is Nothing) Then Msgbox "Could not create the Sessions collection object. Stopping macro playback." STOP End If ' ************************************ ' * Get the necessary Session Object * ' ************************************
Set Sess0 = System.ActiveSession If (Sess0 is Nothing) Then Msgbox "Could not create the Session object. Stopping macro playback." STOP End If If Not Sess0.Visible Then Sess0.Visible = TRUE Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' ********************* ' * Initial Variables * ' *********************
g_HostSettleTime = 100 lines = 0 reset
' ******************** ' * Open Output File * ' ********************
if (dir$("c:\CICS Screens",16) = "") then MkDir "c:\CICS Screens" end if Savefilename$ = "c:\CICS Screens\" + Format(now(),"yy-mm-dd hh.nn.ss") + ".txt" Open Savefilename$ For Output As 1
' **************** ' * Grab Screens * ' **************** call SendScreen
' ************* ' * Closedown * ' ************* CloseDown: close #1 reset msgbox (lines + " lines written to " + Savefilename$)
Set Sess0 = Nothing Set Sessions = nothing Set System = nothing Exit Sub ErrProc:
msgbox ("There was an error!") resume closedown
End Sub
private sub SendScreen
TopLine$ = "*&*&*&*TOP*&*&*&*" BottomLine$ = "*&*&*&*BOTTOM*&*&*&*"
print #1, topline lines = lines + 1 current_page$ = Sess0.Screen.GetString (1, 1, 24*80)
for lin = 1 to 24 thislin = mid$(current_page$, (80 * lin) - 79, 80) Print #1, thislin lines = lines + 1 next lin print #1, BottomLine lines = lines + 1
end sub |
|