problem with getdisplaytext using interop.reflection/reflectionhost
Hi good day , Im developing an application to extract information from reflection, my problem is that it seems like the application is not storing the data everytime I run it, sometimes it stores some of ir others it doesnt. Would like to know if someone knows of a solution for this without thread.sleep.
My code:
Code:
Public Class _Reflection
Public MyWRQ As Reflection.Session
Public Sub Session_Connect(ByVal User As String, ByVal Password As String, Optional visible As Boolean = False)
MyWRQ = New Reflection.Session
With MyWRQ
.Visible = visible
.OpenSettings(1, "\Program Files (x86)\\Reflection\tnp1.rsf")
.Connect()
.HostcommTimeout = 10
WaitForString("APPLICATION", 8, 7)
Evento(HostEventos.Atposition, 9, 18)
.TransmitANSI("MXMP")
.TransmitTerminalKey(HostEventos.rcIBMEnterKey)
WaitForString("Userid", 23, 3)
Evento(HostEventos.Atposition, 23, 11)
.TransmitANSI(User)
.TransmitTerminalKey(HostEventos.rcIBMTabKey)
.TransmitANSI(Password)
.TransmitTerminalKey(HostEventos.rcIBMEnterKey)
End With
End Sub
Public Sub SendTerminalKeys(ByVal key As Integer)
MyWRQ.TransmitTerminalKey(key)
MyWRQ.WaitForEvent(1, "150", "0", 1, 1)
End Sub
Public Function GetString(ByVal Row As Integer, ByVal Column As Integer, ByVal CharLength As Integer) As String
MyWRQ.WaitForEvent(1, "150", "1", 1, 1)
Do Until MyWRQ.GetDisplayText(Row, Column, CharLength).Trim <> "" : Loop
Return MyWRQ.GetDisplayText(Row, Column, CharLength).Trim
End Function
Public Sub WaitForString(ByVal Str As String, ByVal Row As Integer, ByVal Column As Integer)
MyWRQ.WaitForDisplayString(Str, "150", Row, Column)
MyWRQ.WaitForEvent(1, "150", "0", 1, 1)
End Sub
Public Sub Evento(ByVal Evento As Integer, ByVal Row As Integer, ByVal Column As Integer)
If Evento = 6 Then
MyWRQ.WaitForEvent(1, "150", "0", 1, 1)
MyWRQ.WaitForEvent(6, "150", "0", Row, Column)
Else
MyWRQ.WaitForEvent(Evento, "150", "0", Row, Column)
End If
End Sub
Public Sub MoveCursor(ByVal Row As Integer, ByVal Column As Integer)
MyWRQ.MoveCursor(Row, Column)
End Sub
Public Sub Session_Disconnect()
MyWRQ.Exit()
End Sub
end class
this is the part where it sometimes store some of the values on some of the variables others it doesnt
Code:
Public Sub RESETSCRN(ByVal Hst As ReflectionHost._Reflection, ByVal Screen As String)
With Hst.MyWRQ
.TransmitTerminalKey(ReflectionHost._Reflection.HostEventos.rcIBMClearKey)
Hst.Evento(1, 1, 46)
Hst.MyWRQ.TransmitANSI(Screen)
.TransmitTerminalKey(ReflectionHost._Reflection.HostEventos.rcIBMEnterKey)
Hst.Evento(1, 1, 46)
End With
End Sub
public sub process()
RESETSCRN(Hst, "IINQ")
Hst.WaitForString("ARTC", 1, 2)
Hst.MyWRQ.TransmitANSI("100297910")
Hst.SendTerminalKeys(ReflectionHost._Reflection.HostEventos.rcIBMEnterKey)
IINQCWO = Hst.GetString(19, 25, 1) 'CANCEL WHEN OUT N
IINQREPLN = Hst.GetString(8, 9, 5) 'RESURTIBLE 33,37,20
IINQACTIVE = Hst.GetString(1, 19, 6) 'STATUS ACTIVO
IINQMBM = Hst.GetString(19, 12, 1) 'MBM M O I
IINQVIGENCIA = Hst.GetString(18, 37, 8) 'VIGENCIA ABIERTA
end sub
thanks a lot
Re: problem with getdisplaytext using interop.reflection/reflectionhost
found the problem , dont quite get the difference between both but theres a getfieldtext method which is working correctly insted of getdisplaytext