Jump to content
Macro Express Forums

Dynamically reading array variables, or dynamic array variables

Recommended Posts

I've been looking for this for more then a day now, but can't find anything. Not on the forum, not in the documentation.


I'm trying to read variables from an array dynamically, I use Macro Express Pro


This doesn't work:



But this does:



If I assign the value of %N[5]% to %ElementLast%, it works.


-Am I missing something, or is this not possible at all?


Thanks for any input on this request.


Best regards,

Link to comment
Share on other sites

Looks like a bug, report it.


Leon I think your running into a problem that you would not have if you take advantage of named variables. In ME3 we were limited to a few arrays for each type. IE each variable had to be an array element. With named varaibles the overwhelming majority of these could now be 'normal' variables. I don't know what you are doing but I'm willing to bet that if you gave %T[whatever]% a variable name like %LastName% or %N[5]% a name like %Index% you would avoid the problem.

Link to comment
Share on other sites

This doesn't work:


It does for me!

Try this code and let us know what your results are:

<VARIABLE SET STRING Option="\x00" Destination="%t[1]%" Value="First" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%t[2]%" Value="Second" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%t[3]%" Value="Third" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%t[4]%" Value="ourth" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%t[5]%" Value="Fifth" NoEmbeddedVars="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%n[1]%" Value="1"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%n[2]%" Value="2"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%n[3]%" Value="3"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%n[4]%" Value="4"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%n[5]%" Value="5"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 The 5th element of t1 is %t[5]%\r\n\\par \r\n\\par The nth element of t1 is %t[%n[5]%]%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Link to comment
Share on other sites


Thanks for the quick reply.


I'm basically only using these in macro's for short jobs which are called from the main macro, e.g. renaming something, calculating something, etc. It's also a bit of a mental thing for me, that the original arrays T, N, D, etc, are used for temporary things, and the named variables are used in the main macro as to not accidentally mix.


Yes, I also know of the Variable Save and Restore commands.


To be honest, named variables was one of the big reasons for me to go to Macro Express Pro.




Also thanks for the quick reply.


I'm not at the machine I use with Macro Express Pro, but downloaded the trial and tried it on an XP machine using your code, and indeed IT DOES WORK on there.


I really don't understand as the combination you used is the 1st one I tried, because it's the logical combination to use.


My Macro Express Pro machine uses windows 2000 SP4, so this evening I'm going to past you're code in there to see what happens.


This really puzzles me, and makes me think of having overlooked something very simple initially.



Both Paul and Cory, thanks very much for the quick replies, much appreciated.


Best regards,

Link to comment
Share on other sites

Windows 2000? Oh, please tell me it ain't so.


In that same spirit of getting on so nicely, I'm always willing to oblige. ;)


It ain't so. :wacko:


Anyhow, this one was my bad. I had made an error in the script which caused the array variable to be used as identifier to be 0, and that doesn't work. Stupid me, wasted a lot of time on this.


Thanks again, and best regards,


PS: If it ain't broke, don't fix it. If it does the job, don't change it. If ones satisfied with it, don't update it. If one doesn't need the "new features", leave it. :) :)

Link to comment
Share on other sites

PS: If it ain't broke, don't fix it. If it does the job, don't change it. If ones satisfied with it, don't update it. If one doesn't need the "new features", leave it. smile.gifsmile.gif

In most circumstances I agree with you. But when comparing W2k with W7, well, really, you're missing out on so much. W7 is so good, compared with everything that went before.

Link to comment
Share on other sites

I know of two major companies still running W2kP!


In other programming languages array pointers are zero based and the default value of an integer is zero so this has caught me out before as well.


BTW in proper programming languages most follow conventions with names for ease of visual ID. For instance a string var is prefaced "str", integers "int". EG: "strLastName", "intCounter". You could do the same. in MEP.

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