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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop macro question

Status
Not open for further replies.

afortuna98

Programmer
Apr 4, 2014
28
0
0
US
What I am wanting to do is have the macro check a specific screen location in Attachmate for any value other than nothing. If there is a value, then continue running the macro, if there is nothing then stop running the macro. I've tried using the following, but it isn't working:

Location = Trim(Sess0.Screen.GetString (8,31,1))
If Location = "" Then
STOP
End IF

If I use the word "STOP" then it compiles fine, but ignores the IF/Then statement. If I use the word "EXIT" then I get a Syntax Error for the word "EXIT" and the "End If" becomes an illegal statement. I've been able to use something similar for placing values into an Excel cell when there is nothing on the Attachmate screen location:

Location = Trim(Sess0.Screen.GetString (8,31,1))
If Location = "" Then
obj.WorkSheets("Quarterly Macro").Cells(3, "A").Value = 0
End IF

I'm missing something.
 
Hi,

"If I use the word "STOP" then it compiles fine, but ignores the IF/Then statement."

How do you know that. Nothing in the code you posted would give that indication!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
BTW, if you are grabbing data from tour terminal emulator and writing to Excel, then by coding in Attachmate, you're coding in the Yugo, when you could be coding in the Jaguar.

You'll still need to create the Attachmate objects, but all the Excel objects will exist in Excel VBA. Excel VBA is orders of magnitude better than Attachmate VBA.

Regarding your issue, usually you're testing for the presence of a value AFTER having issued a SendKeys to fetch data from the system. So FIRST you have to WAIT for the asynchronous system to respond by returning a screens worth of data. Testing BEFORE the system has responded is futile!

I usually use WaitForCursor at the screen rest point, within a Do Loop.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
How do you know that. Nothing in the code you posted would give that indication!" I ran it on two separate accounts, one that matched the criteria and one that did not. It continued on as if nothing had happened on both.

"Regarding your issue, usually you're testing for the presence of a value AFTER having issued a SendKeys to fetch data from the system. So FIRST you have to WAIT for the asynchronous system to respond by returning a screens worth of data. Testing BEFORE the system has responded is futile!" I'll take a look at this and see what I can do. I think I know what you are talking about, atleast my head is telling me I do. :)
 
That position might contain a control character, so Trim() would be insufficient. You might try testing the instance that appears to be nothing to determine the ASCII value.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top