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!

Trying to spot array error

Status
Not open for further replies.

flowersr

MIS
Feb 11, 2004
43
US
Hi,

I am new at this Attachmate stuff and was hoping someone can tell me why I am getting an error on my IF statement? I am guessing it is in my declaration somewhere.

Thanks, Rich

--------- code -----------

global CWF_scr(3)

declare function chkpos_screen() as integer

CWF_scr(1) = 01
CWF_scr(2) = 25
CWF_scr(3) = "CWF PART A"

if (chkpos_screen(CWF_scr) <> 1) then ' <-- error
...
end if

'-------------------------------
function chkpos_screen( cMsg() )
'-------------------------------

dim iL as integer
dim iP as integer
dim tStr as string
dim lStr as integer

iL = cMsg(1)
iP = cMsg(2)
tStr = cMsg(3)
lStr = len(tStr)

if ( tStr = mid(Screen(iL), iP, lStr) ) then
return 1
else
return 0
end if

end function
 
Hi,

Code:
if (chkpos_screen(CWF_scr) <> 1) then       '  <-- error
1. CWF_scr is an array, so you must reference with an index.

2. chkpos_screen() is a function that has NO VALUE assigned to it in that statement.

Please explain what you are trying to do with this function.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi,

I am looking for text starting at row/column position. I have very many to check as I proceed thru about 10 screens.

CWF_scr(1) is the row where to look
CWF_scr(2) is the column where to look
CWF_scr(3) is the text to look for

The function chkpos_screen is supposed to return the integer 1 if successful otherwise return a 0.

Are you saying I need to do this instead?

retval = chkpos_screen(CWF_scr)
if retval <> 1 then
...
end if

Thanks,
Rich



 
Code:
'CWF_scr(1) is the row where to look
'CWF_scr(2) is the column where to look
'CWF_scr(3) is the text to look for 
If YourScreenObject.GetString(CWF_scr(1),CWF_scr(2),Len(CWF_scr(3))) = CWF_scr(3) then
  msgbox "houston, we have a match!"
end if


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
SkipVought,

I will give that a try.

Thank-you,
Rich
 
Code:
Option Explicit

Declare Function Check_Screen_Position(Sess As Object, row_no As Integer, col_no As Integer, search As String) As Integer

Sub Main()
   Dim Sys As Object, Sess As Object

   Set Sys = CreateObject ( "Extra.System" )

   If Sys Is Nothing Then
      MsgBox ( "Could not create Extra.System...is E!PC installed on this machine?" )
      Exit Sub
   End If

   Set Sess = Sys.ActiveSession

   If Sess Is Nothing Then
      MsgBox ( "No session available...stopping macro playback." )
      Exit Sub
   End If

   Dim CWF_scr(3) As Variant

   CWF_scr(1) = 01
   CWF_scr(2) = 25
   CWF_scr(3) = "CWF PART A"
   
   If Check_Screen_Position(Sess, CWF_scr(1), CWF_scr(2), CWF_scr(3)) Then
      Msgbox "FOUND"
   Else
      Msgbox "NOT FOUND"
   End If
End Sub

Function Check_Screen_Position(Sess As Object, row_no As Integer, col_no As Integer, search As String) As Integer
   MsgBox Sess.Screen.GetString(row_no, col_no)
   
   If InStr(1, Ucase(Sess.Screen.GetString(row_no, col_no)), Ucase(search)) > 0 Then
      Check_Screen_Position = 1
   Else
      Check_Screen_Position = 0
   End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top