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!

Attachmate Macro - Using varieble in IF/THEN 1

Status
Not open for further replies.

OhDavey

Technical User
Jan 27, 2006
5
0
0
US
I'm trying to edit a condition in to an existing Attachmate macro I've created. I need the macro to check a certain location on the screen for the character that is there. If the character is an "L", the macro needs to kick back the dialog box for Location = L. Otherwise, it needs to carry on as normal.

I'm pretty inexperienced with VB, and haven't been able to find a way to 1) Pull the character at that location.(GetString?) 2) Create a check to see if it is an L, and perform the IF/Then statement.

Code:
If [b]Location = L[/b]

Then

Begin Dialog userdialog1 80, 41, "800L ALERT"
   Text  15, 5, 55, 10, "LOCATION = L!"
   CancelButton  15, 20, 50, 14
End Dialog
dim mydialog1 as userdialog1
dialog mydialog1



Else


Begin Dialog userdialog2 115, 44, "800L ALERT"
   Text  40, 5, 35, 10, "Set alert?"
   OkButton  5, 20, 50, 14
   CancelButton  60, 20, 50, 14
End Dialog
dim mydialog2 as userdialog2
dialog mydialog2


	Sess0.Screen.PutString "narr", 3,12 
        Sess0.Screen.Sendkeys("<Enter>")
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
Date1 = Sess0.Screen.GetString (08,11,02)
Date2 = Sess0.Screen.GetString (08,14,02)
Date3 = Sess0.Screen.GetString (08,17,04)
HWFS  = Sess0.Screen.GetString (24,08,07)
 
        Sess0.Screen.MoveTo 7,39
        Sess0.Screen.Sendkeys("<Pf6>")
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.PutString Date1,18,24
        Sess0.Screen.PutString Date2,18,27
        Sess0.Screen.PutString Date3,18,30
        Sess0.Screen.PutString "CR",18,41        
	Sess0.Screen.PutString Date1,18,50
        Sess0.Screen.PutString Date2,18,53
        Sess0.Screen.PutString Date3,18,56
        Sess0.Screen.Sendkeys("<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
        Sess0.Screen.MoveTo 20,17
        Sess0.Screen.Sendkeys("800L: see narr ")
        Sess0.Screen.PutString Date1,20,32
        Sess0.Screen.PutString "/",20,34
        Sess0.Screen.PutString Date2,20,35
        Sess0.Screen.PutString "/",20,37
        Sess0.Screen.PutString Date3,20,38
        Sess0.Screen.PutString " ",20,42
        Sess0.Screen.PutString HWFS,20,43
        Sess0.Screen.Sendkeys("<Enter>")
        
	System.TimeoutValue = OldSystemTimeout

End If

End Sub
 


hi,

the syntax for If...Then...Else is...
Code:
IF [i]expression[/i] Then
'  stuff to do when [i]expression[/i] is TRUE
Else
'  stuff to do when [i]expression[/i] is FALSE
End If
You have Then on a separate line, which is interpreted as a different statement.



Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Yar. I think that's just a formatting error from when I pulled it over. It's correct in my code. The issue I am having is how do I capture the information at that location, recognize if it is an "L" or not, and then finish out the macro based on which one it is?
 


how do I capture the information at that location
Use GetString. But you must know the row,col coordinates.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks for the quick replies. It seems like I am close with what I have, but it's still not working. Even when there is an L in the location I've pointed it at, it still runs the macro as though it wasn't.

Here's the full code

Code:
Location = Sess0.Screen.GetString (04,74)

        
If Location = "L" Then

Begin Dialog userdialog1 80, 41, "800L ALERT"
   Text  15, 5, 55, 10, "LOCATION = L!"
   CancelButton  15, 20, 50, 14
End Dialog
dim mydialog1 as userdialog1
dialog mydialog1



Else


Begin Dialog userdialog2 115, 44, "800L ALERT"
   Text  40, 5, 35, 10, "Set alert?"
   OkButton  5, 20, 50, 14
   CancelButton  60, 20, 50, 14
End Dialog
dim mydialog2 as userdialog2
dialog mydialog2


	Sess0.Screen.PutString "narr", 3,12 
        Sess0.Screen.Sendkeys("<Enter>")
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
Date1 = Sess0.Screen.GetString (08,11,02)
Date2 = Sess0.Screen.GetString (08,14,02)
Date3 = Sess0.Screen.GetString (08,17,04)
HWFS  = Sess0.Screen.GetString (24,08,07)
 
        Sess0.Screen.MoveTo 7,39
        Sess0.Screen.Sendkeys("<Pf6>")
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.PutString Date1,18,24
        Sess0.Screen.PutString Date2,18,27
        Sess0.Screen.PutString Date3,18,30
        Sess0.Screen.PutString "CR",18,41        
	Sess0.Screen.PutString Date1,18,50
        Sess0.Screen.PutString Date2,18,53
        Sess0.Screen.PutString Date3,18,56
        Sess0.Screen.Sendkeys("<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
        Sess0.Screen.MoveTo 20,17
        Sess0.Screen.Sendkeys("800L: see narr ")
        Sess0.Screen.PutString Date1,20,32
        Sess0.Screen.PutString "/",20,34
        Sess0.Screen.PutString Date2,20,35
        Sess0.Screen.PutString "/",20,37
        Sess0.Screen.PutString Date3,20,38
        Sess0.Screen.PutString " ",20,42
        Sess0.Screen.PutString HWFS,20,43
        Sess0.Screen.Sendkeys("<Enter>")
        
	System.TimeoutValue = OldSystemTimeout

End If
End Sub
 


Code:
Location = Sess0.Screen.GetString (04,74[b],1[/b])
I usually make it a practice when scraping a screen to Trim the result...
Code:
Location = Trim(Sess0.Screen.GetString (04,74[b],1[/b]))


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
If I'm debugging, I'll find out what the macro is reading so after
Code:
Location = Sess0.Screen.GetString (04,74,1)
(adding the extra ",1" as Skipvought says)

I would temporarily bung in

Code:
msgbox Location

so you can see what it's actually picking up
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top