Jump to content
Macro Express Forums

Multiple element variables - What would the code be, within a loop, for assigning and referencing an element's current value?


Recommended Posts

I can't see in the Help how to do this. 'Grateful if you can help.

 

I'm confused about getting values from a multi-element variable from a of pre-run list of values.


(I have created a variable %CB% that has a list of text values  CB 11   CB 12   CB 13 etc. )

By the way, I don't know what the 'Caption' box means in the Variable Set String dialog box.

 

I'd like to know what the the script code is to create a 4-iteration loop that...


- Grabs the first element value of %CB% and types that value into NotePad (which is the declared context the macro has been told to use) at the NotePad cursor position at that moment

 

- Then at the next iteration of the loop, grabs the next element value of %CB%, and pastes that into NotePad where the cursor currently is.

 

- 'Repeating the process to get and paste CB 13, etc.

 

Link to comment
Share on other sites

I'm not sure where the four values are coming from, but assume they're random numbers between 100 and 999:

 

// Generate random values for %CB[1]% ... %CB[4]%
Repeat Start (Repeat 4 times)
  Variable Set Integer %CB[%x%]% to a random value between 100 and 999
End Repeat
 
// Output the four random values
Repeat Start (Repeat 4 times)
  Text Type (Simulate Keystrokes): CB[%x%]  = %CB[%x%]%<ENTER>
End Repeat

 

<COMMENT Value="Generate random values for %CB[1]% ... %CB[4]%"/>
<REPEAT START Start="1" Step="1" Count="4" Save="TRUE" Variable="%x%"/>
<VARIABLE SET INTEGER Option="\x05" Destination="%CB[%x%]%" Minimum="100" Maximum="999"/>
<END REPEAT/>
<COMMENT/>
<COMMENT Value="Output the four random values"/>
<REPEAT START Start="1" Step="1" Count="4" Save="TRUE" Variable="%x%"/>
<TEXT TYPE Action="0" Text="CB[%x%]  = %CB[%x%]%<ENTER>"/>
<END REPEAT/>

 

Sample output:

 

CB[1]  = 548
CB[2]  = 611
CB[3]  = 114
CB[4]  = 595

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...
×
×
  • Create New...