Input not returning variables

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Input not returning variables

Post by xavram »

I have an input screen thats dynamically generated, looks like...

junkVar||Set the number for each spell to memorize|LABEL|TEXT=FALSE##0spellIndex|1|Charm Monster|TEXT|WIDTH=6##1spellIndex|0|Cure Serious Wounds|TEXT|WIDTH=6##2spellIndex|2|Dispel Magic|TEXT|WIDTH=6##3spellIndex|0|Displacement|TEXT|WIDTH=6##4spellIndex|0|Fireball|TEXT|WIDTH=6##5spellIndex|0|See Invisibility|TEXT|WIDTH=6##6spellIndex|0|Terrible Remorse|TEXT|WIDTH=6##7spellIndex|0|Unadulterated Loathing|TEXT|WIDTH=6

...and this displays just fine. However, after I press okay, I want to cycle through each of the "1spellIndex", "2spellIndex", etc, etc variables and do something with whatever the user entered.

But I get an error when I even try to do..

[broadcast(1spellIndex)]

...let alone try to cycle through each of them. I know how many there are to cycle through, given the users input, so I'm not worried about trying to access, say, "7spellIndex" if it only goes up to 6.

Is there a way to skin this cat that I'm not seeing? Thanks!

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Input not returning variables

Post by aliasmask »

Try changing the name format. I don't know if this is the problem but standard variable naming practice is to not use a number as the first character.

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Input not returning variables

Post by xavram »

I'll give that a whirl, thanks!

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Input not returning variables

Post by xavram »

Had to do some additional tweaking, but got it all squared away...thanks!

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Input not returning variables

Post by xavram »

Hmmm...revisiting this thread, sorry about that.

I have this generating right, the input screen shows up just fine...

[h : inputStr = inputStr + "##si" + indexCounter + "|" + skillValue + "|" + skill + "|TEXT|WIDTH=3"]

...but I can't access the variables that get generated, not dynamically anyway.

So I can call...

[r : si6]

...and get back what I had entered in this variable in the input box. But I can't do...

[FOR(i,0,indexCounter), code : {
[r : "si" + i]
}]

...and of course, i get back "si1", "si2", etc, etc....NOT what was set in these variables.

Is there a way to achieve this?


xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Input not returning variables

Post by xavram »

Thank you!!! Didn't realize eval worked for this kind of scenario! Perfect!

Post Reply

Return to “Macros”