This method searches the Fields collection for the target string. The
string must be completely contained within the field to be considered
a match.
Fields.FindByString( TargetString, start, length, dir, IgnoreCase )
Parameter |
Description |
TargetString |
The target string to search for. |
start |
The offset location where the search will begin. For row 1 column 1 of the screen display buffer, the offset is 0. |
length |
The length from start to include in the search. |
dir |
An OHIO_DIRECTION value which represents the direction of the search. |
IgnoreCase |
Indicates whether the search is case sensitive. True means that case will be ignored. False means the search will be case sensitive. |
|
Public AllSessions As OhioSessions Private Sub Form_Load() Set AllSessions = New OhioSessions MySession.Connect End Sub ' get the current fields Dim i As Integer AllFields.Refresh Set MyField = AllFields.Item(i) Next i End Sub Private Sub cmdSendKeys_Click() MyScreen.SendAid OHIO_KEY_ENTER End Sub Private Sub MySession_OnSessionChanged(ByVal oState As OHIO_STATE) Set AllFields = MyScreen.Fields End Sub Private Sub MySession_OnScreenChanged(ByVal inUpdate As OHIO_UPDATE, ByVal inStart As Long, ByVal inEnd As Long) Dim MyField As OhioField ' try finding the word "logon"
on the screen MsgBox "Found string 'logon' at Field
starting at position: " & MyField.Start MsgBox "Same Field" End If End If End Sub Private Sub Form_Unload(Cancel As Integer) MySession.Disconnect End Sub |
|
#define OHIO_STATE_DISCONNECTED 0 BEGIN_DISPATCH_MAP(CMyView, CView) DISP_FUNCTION_ID(CMyView, "OnSessionChanged", 0, OnSessionChanged, VT_EMPTY, VTS_I4)DISP_FUNCTION_ID(CMyView, "OnScreenChanged", 1, OnScreenChanged, VT_EMPTY, VTS_I4 VTS_I4 VTS_I4) END_DISPATCH_MAP() void CMyView::OnSessionChanged(long iState) if ( iState == OHIO_STATE_CONNECTED ) m_AllFields = m_MyScreen.GetFields(); } if ( iUpdate == OHIO_UPDATE_HOST ) m_AllFields.Refresh(); IOhioField MyField1 = m_AllFields.FindByString(
"logon", 0, 80*24, OHIO_DIRECTION_FORWARD, TRUE ); TRACE( "Found string 'logon' at Field starting at position: %d\n", MyField1.GetStart() ); IOhioField MyField2 = m_AllFields.FindByPosition(
MyField1.GetStart() ); } } } |
|
try { PASSHIOLib.IOhioFields AllFields = screen.Fields; PASSHIOLib.IOhioField MyField; PASSHIOLib.IOhioField MyField1; AllFields.Refresh(); MyField = AllFields.FindByString( "logoff", 0, screen.Rows*screen.Columns, PASSHIOLib.OHIO_DIRECTION.OHIO_DIRECTION_FORWARD, 1 ); if ( MyField != null) { MessageBox.Show ( "Found string 'logoff' at Field starting at position: " + MyField.Start ); MyField1 = AllFields.FindByPosition( MyField.Start ); // should refer to the same field MessageBox.Show ("Field starting at " + MyField.Start + " = " + MyField1.String); } } catch (Exception ex) { MessageBox.Show ("Exception: " + ex); } |