Jump to content
Macro Express Forums

Step Thru An Array Of Vars


ffortino

Recommended Posts

Hi ffortino,

 

I don't believe so.

 

One way to get round this would be to append all the T variables to a file (CRLF after each one), then process the file using TEXT FILE BEGIN PROCESS. This would process one value at a time in a loop.

 

Maybe you could populate the file instead of the T variables initially ?

 

Pete.

Link to comment
Share on other sites

Hello ffortino!

 

There are no arrays in Macro Express, but a linear sequence of variable numbers can be stepped through like an array. The following code stuffs string variables T1 through T99 with values from the Registry. Is this what you are thinking about? We do this in several areas of our PGM Functions Library.

Repeat Start (Repeat 99 times)
 Read Registry String: "T%N1%"
Repeat End

And there are other sophisticated ways of handling variables such as using dynamic macros.

VarLoop.zip

Link to comment
Share on other sites

  • 2 years later...

Is this method available in macro express itself?

 

I am trying to read in lines from a file, and fill sequential variables from those lines.

BUT, the "variable from file" method, just fills in T1 (or whqatever I start with), doesn't do anhy sequential fill, because each line is just a line, not any csv delimited setup.

 

Any way to read LINES in from a file, to sequential variables?

Line 1 goes to T1, line 2 goes to t2, etc?

thanks

NIck

Link to comment
Share on other sites

In order for this example to work you need to set the 'Variables Evaluation Level' to 1 or larger. If you are using Macro Express v 3.7 or later you can set this by clicking Options, Preferences, Miscellaneous and then the Advanced button. For v 3.6 and prior, download TweakME3.mxe from the More Macro Express Downloads page and run it to change the 'Variables Evaluation Level'.

 

Something like this should work:

// Initialize N1 to 10 so first line is copied to variable T10
Variable Set Integer %N1% to 10
// Initialize N2 used for counter
Variable Set Integer %N2% to 10

Text File Begin Process: "test.txt"
 
 // Do not exceed the number of available variables (T99 is the last variable)
 If Variable %N2% > 99
   Break
 Else
   
   // The next two commands copy T1 to T%N1%
   Variable Set String %T2% "<TMVAR2:09:%N1%:01:000:000:>"
   Run Macro in Variable %T2%
 End If
 
 // Increment the counter
 Variable Modify Integer: Inc (%N2%)
Text File End Process

// Here: Variable T10 through up to T99 contain contents of the file c:\test.txt

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...