Jump to content
Macro Express Forums

How to increment variable to another variable?


Shai
 Share

Recommended Posts

I'm trying to do a search for a series of 30 contiguous pixel colors in the positive X direction from a set of integer variables set to specific color values. When the first value is found the macro will increment to the next X coordinate and test for the second pixel color. Basically a repeat loop is going to fetch %N1% which is the first pixel color and put it into %N31%. When %N31%, which is set to %N1%'s value, is found the X coordinate will be incremented by 1 and then %N31% needs to be set to %N2% which is the second pixel color I'm looking for. This is where I'm having the problem. How to make %N31% = %N1%, then %N31% = %N2%, then %N3% and so forth. I'd like to have this in some efficient logic that increments N31 to N1 or N2 or N3 etc based on a repeat counter. But ATM I can only see to do it manually with 30 written checks. Is there a way to do this? I'm not a programmer, a hobbyist perhaps, but I'm guessing this might be a "boolean variable" falling in the domain of Macro Express Pro?

Link to comment
Share on other sites

Instead of putting your color values into N1 through N30, put them one after another into a single text variable:

VARIABLE SET STRING T1 = 12345678 23456789 34567890 45678901 and so on.

The blank spaces between values are for your benefit, to make it readable.

Then each time you want to retrieve a value, move 8 characters to a second text variable, load the integer from the second text variable, and remove the nine characters from the first text variable:

VARIABLE MODIFY STRING T1: COPY CHARACTERS 1-8 FROM T1 TO T2

VARIABLE MODIFY STRING T1: DELETE CHARACTERS 1-9

VARIABLE MODIFY STRING T2: CONVERT TO INTEGER IN N31

Link to comment
Share on other sites

Set the appropriate ME option to allow nested variables (refer to Kevin's response here: Variable Evaluation Level).

 

Then store the repeat counter into a variable (let's use %n99% in this example), and reference the source variables for %n31% in your repeat loop with:

Variable Set Integer %n31% to %n%n99%%

When %n99% is 1, this command sets %n31% to the value of %n1%; when %n99% is 28, this command sets %n31% to the value of %n28%.

Link to comment
Share on other sites

Set the appropriate ME option to allow nested variables (refer to Kevin's response here: Variable Evaluation Level).

 

Then store the repeat counter into a variable (let's use %n99% in this example), and reference the source variables for %n31% in your repeat loop with:

Variable Set Integer %n31% to %n%n99%%

When %n99% is 1, this command sets %n31% to the value of %n1%; when %n99% is 28, this command sets %n31% to the value of %n28%.

I had tried to do this before but ME complained, thanks a bunch.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...