pixel ranges, sub routines, variables, and %variable%

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

pixel ranges, sub routines, variables, and %variable%

Post by Snickers » Thu Dec 15, 2005 5:08 pm

couple items i need a better mental picture of please. I have used the search feature but have not found an answer to my questions.

I have numbered the lines for reference

this is my current code (extremely simplified):

1 //declare variable at start of macro
2 Let>A=12345
3 Let>B=6789
4
5 IF>{(%zone%1580000)}
6 GoSub>NZONECALC
7 Goto>NARROWZONE
8 EndIF
9
10 IF>{(%zone%2700000)}
11 GoSub>NZONECALC
12 Goto>NARROWZONE
13 EndIF
14
15 IF>{(%zone%1060000)}
16 GoSub>NZONECALC
17 Goto>NARROWZONE
18 EndIF
19
20 SRT>NZONECALC
21 ------------code-------------
22 Goto>(for example START or END)
23 END>NZONECALC
24
25 Label>NARROWZONE
26 ------------code-------------
27 Goto>START
28
29 Label>END

QUESTION 1:
Is it possible to search for those ranges with just one IF statements? For example:

IF>{((%zone%1580000)) or ((%zone%1060000)) or ((%zone%2700000))}

QUESTION 2:
My belief is that the script program runs from top to bottom unless you tell it to go somewhere else. If line 5 turns out to be true, the script will go to line 6 and then be sent to line 20, SRT>NZONECALC. It will then run lines 20-23 and then go to line 7.

Is this correct? Is this the way subroutines work? If you call a subroutine, will it run the subroutine and then return to the line where you first called that subroutine?

QUESTION 3:
Does the script only do one line at a time or can I have it do multiple subroutines at the same time?

QUESTION 4:
If I am inside of a subroutine--line 22--, can I send the program to a label outside, above, and/or below the subroutine?

QUESTION 5:
Is there a limit to the number of variables my scripts may have?

QUESTION 6:
After lines 1,2,and3 have been run, will the program always remember those variables?

QUESTION 7:
Will those variables set during lines 1,2,and3 be available within my subroutine or is it possible to declare variable that are ONLY available to my subroutine and if so, how?

QUESTION 8:
When MUST I use % around my variables?

QUESTION 9:
Would removing the empty lines at line 4, 9, 14, 19, 24, and 28 make the macro faster or more efficient?


I'm sorry for so many questions; however, my mental grasp of these concepts aren't covered in the help manual. These would be great additions to the help content.

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

Post by Marcus Tettmar » Thu Dec 15, 2005 5:25 pm

Hi,
QUESTION 1:
Is it possible to search for those ranges with just one IF statements?
Yes. Like this:

IF>{((%zone%1580000)) OR ((%zone%2700000)) OR ((%zone%1060000))}
GoSub>NZONECALC
Goto>NARROWZONE
EndIF
QUESTION 2:
My belief is that the script program runs from top to bottom unless you tell it to go somewhere else. If line 5 turns out to be true, the script will go to line 6 and then be sent to line 20, SRT>NZONECALC. It will then run lines 20-23 and then go to line 7.
Correct
QUESTION 3:
Does the script only do one line at a time or can I have it do multiple subroutines at the same time?
The script executes one line at a time. No, you can't execute subroutines at exactly the same time.
QUESTION 4:
If I am inside of a subroutine--line 22--, can I send the program to a label outside, above, and/or below the subroutine?
Yes
QUESTION 5:
Is there a limit to the number of variables my scripts may have?
No, no limit.
QUESTION 6:
After lines 1,2,and3 have been run, will the program always remember those variables?
Yes, unless you change them of course.
QUESTION 7:
Will those variables set during lines 1,2,and3 be available within my subroutine or is it possible to declare variable that are ONLY available to my subroutine and if so, how?
Yes, all variables are global.
QUESTION 8:
When MUST I use % around my variables?
When embedding them inside some other string or with another variable. you DON'T need to use them when they are on their own (unless you have VAREXPLICIT on).
QUESTION 9:
Would removing the empty lines at line 4, 9, 14, 19, 24, and 28 make the macro faster or more efficient?
Technically the macro will run faster if it has less lines to process, so, the technical answer is yes. In practice though you won't notice a thing. We're talking about nano-seconds or less! Leave them in to make the macro easier to read.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Dec 15, 2005 5:51 pm

You are great--mtettmar! Super fast and accurate responses. Gota love it. Thank you!

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