Jump to content
Macro Express Forums

Able To Use Variable In Variable Names?


jmb4370
 Share

Recommended Posts

Which command are you using dynamically in the repeat loop? Here is an example using the Set with Random Letter command:

Repeat Start (Repeat 90 times)
 Variable Set String %T1% "<TVAR2:%N1%:12:>"
 Run Macro in Variable %T1%
Repeat End

<REP3:01:000010:000001:00090:1:01:><TVAR2:01:01:<TVAR2:%N1%:12:>><RUNMACVAR:1><ENDREP>

Link to comment
Share on other sites

Floyd,

I'm not sure I understand how you got this section in the command: "<TVAR2:%N1%:12:>". Was it through the direct editor by replacing the 01 in the regular command with the %N1% to specify the dynamically changing variable?

I'm using the "ASCII File Begin Process" which will fill up T1, T2, T3, etc from the specified CSV file. Inside a Repeat Loop (before the "ASCII File End Process" command) I want to look up something in another list first using the value stored first in T1, then in T2, then T3, until there are no more items from the first record. So, inside the loop the variable will keep changing, first using T1, then T2, then T3, etc. (Boldface variable T1 in line 3) below)

Is this some of the job of the "Run Macro in Variable" command (which I still don't fullly understand)?

 

1) ASCII File Begin Process

2) Repeat Until %N1% = %N5%

3) Text Type: %T1%

4) Repeat End

5) ACSII File End Process

 

Thanks for your help!

Michael

Link to comment
Share on other sites

Yes, you can switch to the Direct Editor view to see the commands in their native state. I do it anytime I need to create a dynamic section of code. And yes, the Run Macro in Variable command is used to run dynamic code. And so, for that matter, is the Load Macro Text File command.

 

According to your example, you are wanting to type-out the string variables that are filled each time through the file processing loop. Is this correct?

Link to comment
Share on other sites

Yes, that's correct for this example. The first time through the Repeat loop the variable is T1 and prints the first field that was stuffed from the record filled by the ASCII File Begin/End Process commands. The next time through the Repeat loop, the variable should be T2 to print (and other stuff as necessary) the second field that was generated by the ASCII File Begin command. This Repeat loop will continue until there are no more fields that were filled from the ASCII File Begin Process. A likely test to determine how many fields were filled would be when the next variable has a zero ASCII value, Then the number of fields is this increment minus one.

 

Michael

Link to comment
Share on other sites

  • 2 years later...

I'm bumping this because it's a similar issue I'm having.

 

I have a text file I process into T10. First problem is right here. When I go to typetext %T10% %T11% etc... %T10% is the only variable with a value in it. I was under the impression that CR's in a text file counted as a line, and each line was read into an incremented variable.

format of the text file:

1

2

3

4

5

6

etc.

Currently texttype: %T10% responds with 12345678etc.

 

I then want to sequentially compare the values of T, requiring me to increment T10-TXX in a loop.

Link to comment
Share on other sites

When using the Text File Begin Process command, each time it loops places one line in the same variable.

 

When using the ASCII File Begin Process command, each time it loops it parses each line into separate fields. The first field is put in the variable specified by the 'Variable to Receive First Field' option in the dialog. Each subsequent field on that line is placed in a subsequent variable. Eg: if the first variable is in T10, and each line contains 5 fields, then they will be placed in T10, T11, T12, T13 and T14.

 

When the ASCII File Begin Process command loops again it will place the fields from the next line into T10 through T14.

 

Some macros require that one variable access another one. A discussion about this, along with a sample macro, is found in section 4 of the Macro Express News email newsletter from July 15, 2005. This article links to a sample macro described on the Variable Evaluation Level web page.

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