Hi,
I want catch lines from screen Extra and put into txt file. How I can do this?
I try macros examples from Extra. But the CreateObject("EXTRA.System") method fails in windows 7.
Sub Main()
'--------------------------------------------------------------------------------
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System")
If (System is Nothing) Then
Msgbox "Error macro 1."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Error macro 2."
STOP
End If
'--------------------------------------------------------------------------------
g_HostSettleTime = 3000
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Error macro 3."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Dim MaxCols as Integer
MaxCols% = Sess0.Screen.Cols
Dim MaxRows as Integer
MaxRows% = Sess0.Screen.Rows - 3
Dim Buffer as String
Buffer$ = ""
Dim LineBuffer as String
LineBuffer$ = ""
Dim NumLin as String
NumLin = "000000"
Dim Lin as Integer
Lin% = 4
Close
FNum% = FreeFile
Open "C:\file12.txt" for Output as FNum%
Do
LineBuffer$ = Sess0.Screen.GetString (Lin%,1,MaxCols%)
If Right$(Trim$(LineBuffer$),3) = "END" and Right$(Trim$(LineBuffer$),5) <> "DOEND" Then
Buffer$ = Buffer$ + LineBuffer$
Print #FNum%, Buffer$
Exit Do
End If
If Lin% Mod 23 = 0 Then
Buffer$ = Buffer$ + LineBuffer$
Print #FNum%, Buffer$
Lin% = 4
NumLin$ = Left$(LineBuffer$,7)
Buffer$ = ""
Sess0.Screen.Sendkeys("<Pf8>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Else
If Val(Left$(LineBuffer$,7)) > Val(NumLin$) Then
Buffer$ = Buffer$ + LineBuffer$ + Chr$ (13) + Chr$ (10)
End If
Lin% = Lin% + 1
End If
Loop
I almost NEVERTHELESS code in Extra. In my line of work I'm scraping data from the mainfram terminal emulator, to get it into Excel for analysis. So I do nearly ALL my coding in Excel VBA. Excel has a much MUCH better code editor.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.