Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to catch lines from Extra.

Status
Not open for further replies.

Bsb01

Programmer
May 27, 2015
5
BR
Hi,

I,m tried to catch lines from Extra screen.
This code doesn´t work. The system crash at Set System = CreateObject("EXTRA.System").
Windows 7.
Can someone help me?

This is my code:

' Declarações de variáveis globais
Global g_HostSettleTime%

Sub Main()
'--------------------------------------------------------------------------------
' Obtém o objeto principal do sistema.
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Obtém o objeto do sistema.
If (System is Nothing) Then
Msgbox "Não foi possível criar o objeto EXTRA System. Anulando a reprodução da macro."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Não foi possível criar o objeto de coleção Sessions. Anulando a reprodução da macro."
STOP
End If
'--------------------------------------------------------------------------------
' Define o valor do tempo de espera padrão.
g_HostSettleTime = 3000 ' milissegundos

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Obtém o objeto Session necessário.
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Não foi possível criar o objeto Session. Anulando a reprodução da macro."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' Essa seção de código contém os eventos registrados

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:\teste.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

Close

MsgBox "Arquivo disponível em: C:/teste.txt"

System.TimeoutValue = OldSystemTimeout
End Sub



 
do you have Extra installed? your code looks good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top