syntax error

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

syntax error

Post by SuitedAces » Tue Feb 26, 2008 5:35 pm

I'm using the FindIamgePos command
FindImagePos>C:\ocr\openseat.bmp,SCREEN,60,1,x,y,NumFound

Normally to return the x coordinate of the first occurence found you
use:
%x_0%

But I am running into difficulty when I want to look at the coordinates in
succession. How do I replace %x_0%, %x_1% , %x_2% etc with a variable?

I tried the following 3 combinations and all of them produced errors

Let>i=-1
Repeat>i
Let>i=i+1

let>z=%x_%i%%

Until>i,NumFound


Let>i=-1
Repeat>i
Let>i=i+1

let>z=%x%_%i%

Until>i,NumFound



Let>i=-1
Repeat>i
Let>i=i+1

let>z=%%x%_%i%%

Until>i,NumFound


Thank you for your help

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 26, 2008 5:43 pm

Actually you shouldn't be using %x_0%

Do it like this:

Code: Select all

Let>i=0
Repeat>i
  Let>x=x_%i%
  Let>y=y_%i%
  MouseMove>x,y
  LClick
  Let>i=i+1
Until>i=NumFound
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 26, 2008 5:47 pm

The correct syntax is:

Let>i=-1

Repeat>i
Let>i=i+1
let>z=x_%i%
Until>i,NumFound


I want to caution you against using single characters as variable names. The practice will eventually cause you problems. I would prefer you do something like:

Let>kk=-1

Repeat>kk
Let>kk=kk+1
let>value=x_%kk%
Until>kk,NumFound

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Tue Feb 26, 2008 7:58 pm

I forgot to include that attempt in my post ,I but I did tried that also, and got an error

Let>i=-1
Repeat>i
Let>i=i+1

here is my line of code
If>{(x_%i% > 514) AND (x_%i% 65) AND (y_%i%i,NumFound

I get an error that say unknown identifier x_0 on that line.
Zero is correct for i on the first pass but i get an error.
Last edited by SuitedAces on Tue Feb 26, 2008 8:09 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 26, 2008 8:08 pm

You probably need to remove the spaces from the if> line. Unless you have the variable IGNORSPACES set to 1

Because of the rules for complex expressions you will need to pre_capture the value of the array variables to a non array variable. Something like:

Code: Select all


Let>kk=-1

Repeat>kk
Let>kk=kk+1
let>value_X=x_%kk%
let>value_Y=y_%kk%

If>{(%value_X%>514)AND(%value_X%<534)AND(%value_Y%<85)}
Last edited by JRL on Tue Feb 26, 2008 8:13 pm, edited 1 time in total.

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Tue Feb 26, 2008 8:11 pm

JRL wrote:You probably need to remove the spaces from the if> line. Unless you have the variable IGNORSPACES set to 1

Because of the rules for complex expressions you will need to pre_capture the value of the array variables to a non array variable. Something like:

Code: Select all


Let>kk=-1

Repeat>kk
Let>kk=kk+1
let>value_X=x_%kk%
let>value_Y=y_%kk%

If>{(%value_X%>514)AND(%value_X%<534>65)AND(%value_Y%<85>kk,NumFound
please look at my line of code again I needed to reenter it manully because when I pasted it , it jumbled up for some reason.
The form page would not accept a paste of my line of code.
????

That is bizarre

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 26, 2008 8:14 pm

I did re-look at your line and edited mine to make something that made sense. try posting with html and smilies turned off.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 26, 2008 8:19 pm

(x_%i% 65)

is invalid syntax, what condition are you trying to write?

AND (y_%i%i,NumFound

same question about that part too.

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Tue Feb 26, 2008 8:30 pm

Ok I followed that advice and di it this way and still got an error.

Let>i=-1
Repeat>i
Let>i=i+1
FindImagePos>C:\ocr\openseat.bmp,SCREEN,60,1,x,y,NumFound

//Let>seat=0
Let>a=x_%i%
Let>b=y_%i%

If>{(a>514)AND(a65)AND(bseat[%i%]=1
Endif

Until>i,NumFound-1

I get unknown I dentifier 'a'

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Tue Feb 26, 2008 8:31 pm

Ok I followed that advice and did it this way and still got an error.

Let>i=-1
Repeat>i
Let>i=i+1
FindImagePos>C:\ocr\openseat.bmp,SCREEN,60,1,x,y,NumFound


Let>a=x_%i%
Let>b=y_%i%

If>{(a>514)AND(a<534)AND(b<65)AND(b<85)}

I cannot complete the code on the forum ...it gets jumbled
(very bizarre)

but the important line is there

I get unknown identifier 'a'

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 26, 2008 8:54 pm

In complex expressions you MUST have percents around your variables:

If>{(%a%>514)AND(%a%<534)AND(%b%<65)AND(%b%<85)}

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Tue Feb 26, 2008 8:57 pm

Yes I just caught that , LOL.

When you aren't accustomed to these strict syntax rules it can make an idiot out of you real fast.

Thank you very much for the help .

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 26, 2008 9:16 pm

Do you mean b greater than 65? Otherwise it doesn't make any sense to also have less than 85.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 26, 2008 9:24 pm

Bad suggestion deleted :oops:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts