droodled Posted January 31, 2012 Report Share Posted January 31, 2012 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 4.3.0.1. This doesn't work: %T[%N[5]%]% But this does: %T[%ElementLast%]% 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, Quote Link to comment Share on other sites More sharing options...
Cory Posted January 31, 2012 Report Share Posted January 31, 2012 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. Quote Link to comment Share on other sites More sharing options...
paul Posted February 1, 2012 Report Share Posted February 1, 2012 This doesn't work: %T[%N[5]%]% 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"/> Quote Link to comment Share on other sites More sharing options...
droodled Posted February 1, 2012 Author Report Share Posted February 1, 2012 @Cory, 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. @paul, 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, Quote Link to comment Share on other sites More sharing options...
paul Posted February 1, 2012 Report Share Posted February 1, 2012 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. And there we were, getting on so very nicely. Now you've made me cry. Windows 2000? Oh, please tell me it ain't so. Quote Link to comment Share on other sites More sharing options...
droodled Posted February 2, 2012 Author Report Share Posted February 2, 2012 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. 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. :) Quote Link to comment Share on other sites More sharing options...
paul Posted February 2, 2012 Report Share Posted February 2, 2012 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. 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. Quote Link to comment Share on other sites More sharing options...
Cory Posted February 2, 2012 Report Share Posted February 2, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.