Commit e2d9880342519877d9232d91228f0cabc8871e63

Authored by Perry Werneck
1 parent 341b5f1c
Exists in master

Implementando classe VB.NET

Showing 2 changed files with 37 additions and 5 deletions   Show diff stats
src/native/network.cc
... ... @@ -32,6 +32,7 @@
32 32 /*---[ Implement ]----------------------------------------------------------------------------------*/
33 33  
34 34 int tn3270_connect(h3270::session *ses, const char *host, time_t wait) {
  35 + debug("%s(%s,%d)",__FUNCTION__,host,(int) wait);
35 36 return ses->connect(host,wait);
36 37 }
37 38  
... ...
testprograms/vbclass.vb
... ... @@ -49,7 +49,7 @@ Public Class pw3270
49 49 End Function
50 50  
51 51 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
52   - Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal seconds as Integer) as Integer
  52 + Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As String, ByVal seconds as Integer) as Integer
53 53 End Function
54 54  
55 55 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
... ... @@ -89,15 +89,15 @@ Public Class pw3270
89 89 End Function
90 90  
91 91 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
92   - Private Shared Function tn3270_set_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As StringBuilder) as Integer
  92 + Private Shared Function tn3270_set_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer
93 93 End Function
94 94  
95 95 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
96   - Private Shared Function tn3270_wait_for_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal key As StringBuilder, ByVal timeout as Integer) as Integer
  96 + Private Shared Function tn3270_wait_for_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal key As String, ByVal timeout as Integer) as Integer
97 97 End Function
98 98  
99 99 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
100   - Private Shared Function tn3270_cmp_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As StringBuilder) as Integer
  100 + Private Shared Function tn3270_cmp_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer
101 101 End Function
102 102  
103 103 <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _
... ... @@ -130,6 +130,14 @@ Public Class pw3270
130 130 hSession = tn3270_create_session(name)
131 131 End Sub
132 132  
  133 + Public Sub Connect(ByRef url as String, ByVal seconds as Integer)
  134 + tn3270_connect(hSession, url, seconds)
  135 + End Sub
  136 +
  137 + Public Sub Disconnect()
  138 + tn3270_disconnect(hSession)
  139 + End Sub
  140 +
133 141 Public Sub Finalize()
134 142 tn3270_destroy_session(hSession)
135 143 End Sub
... ... @@ -150,6 +158,21 @@ Public Class pw3270
150 158 End Get
151 159 End Property
152 160  
  161 + Public ReadOnly Property Connected As Boolean
  162 + Get
  163 + return tn3270_is_connected(hSession)
  164 + End Get
  165 + End Property
  166 +
  167 + Public Function GetStringAt(ByVal row as Integer, ByVal col as Integer, ByVal strlen as Integer)
  168 + dim buffer As New StringBuilder(strlen)
  169 + tn3270_get_string_at(hSession, row, col, buffer, strlen)
  170 + return buffer.toString
  171 + End Function
  172 +
  173 + Public Sub WaitForReady(ByVal seconds as Integer)
  174 + tn3270_wait_for_ready(hSession, seconds)
  175 + End Sub
153 176  
154 177  
155 178 End Class
... ... @@ -161,8 +184,16 @@ Public Module modmain
161 184  
162 185 dim host as new pw3270("")
163 186  
164   - Console.WriteLine ("Using pw3270 version " + host.Version + " revision " + host.Revision)
  187 + Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision)
  188 +
  189 + host.Connect("tn3270://zos.efglobe.com:telnet",10)
  190 +
  191 + if host.Connected Then
  192 +
  193 + Console.WriteLine(host.GetStringAt(14,19,38))
165 194  
  195 + host.Disconnect()
  196 + End If
166 197  
167 198 End Sub
168 199  
... ...