Jump to content
Macro Express Forums

Dynamic Variable Name


Recommended Posts

I've Macro Express 3.5c and haven't had any "problems" as such untill today..


I'm trying to create a macro that will repeat an "unknown" number of times. I have done so using the Repeat with Variable, command that suites perfectly (imo) however I also need the macro to have an "unknown" number of variables.


In this case I've made variable N99 to have value prompted for by the user. It is used in the Repeat With Variable and sets number of loops. I've also used variable N98 as the Counter variable... I need to create a new variable on each loop and have user prompted for an integer value to be stored in the new variable. However I'm unclear as to wether this is possible and how. Any help would be appreciated.

Link to comment
Share on other sites

Have you investigated/tried "Run Macro in Variable"?

I wrote the following that demonstrates it:

<REM2:This script is limited to a loop of 97.><IVAR2:99:02:FNumber of times to loop?
Note:  No more than 97.FFCenter:Center><IFVAR2:2:99:4:97><TBOX4:T:1:CenterCenter000278000200:000:LimitationThis program has a limit of 97, and will now abort.  Please try again with a lower number.><MSTOP><ENDIF><REM2:N98 - Counter><REP3:05:000001:000001:0099:1:98:><REM2:N99 - Temporary prompting variable to be saved in another (e.g. N1).><REM2:Set your default value that you want the user to see when prompted each time.><REM2:  or REM or delete if you want them to see prior entry.><IVAR2:99:01:0><IVAR2:99:01:1><REM2:Prompt><IVAR2:99:02:FNext input value?TTCenter:Center><REM2:Save prompted value in another variable.><REM2:Copy N99 - Temporary prompting variable to next (e.g. N%N98%) using the counter.><REM2:Sample code to put in Run Macro in Variable.><REM2:You can use any code and put it in a text variable.><REM2:I usually put my commands and then copy them and past inside the set string field.><DIS:<NMVAR:07:99:0:0000001:0:0000000><DIS:<TVAR2:99:01:<NMVAR:07:99:0:0000001:0:0000000>><REM2:T99 - Code to run in macro.><TVAR2:99:01:<NMVAR:07:99:0:000000%N98%:0:0000000>><REM2:Run it.><RUNMACVAR:99><REM2:Do whatever else that needs to be done ...><ENDREP><REM2:TEST RESULTS><TBOX4:T:1:CenterCenter000278000200:000:TestN1	%N1%
N2	%N2%
N3	%N3%>


Copy and paste in a new macro and try it with looping 3 times and see the Test Results. Hope it works out for you. :rolleyes: Please reply whether it works for you or not.



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.

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.

  • Create New...