|
whorn Wanderer
Joined: 04 May 2002 Posts: 52 Location: USA
|
Posted: Fri Jan 02, 2009 6:20 pm
Using a variable to reference a dynamic variable |
So I've been messing with this for awhile and I can't get it to work the way I have envisioned.
Basically I want a variable to be used off the result of a different variable. Here is the trigger I have:
Code: |
Pattern:
- ~[($code:&28)~] - somewhere
Trigger:
#IF (%item( @SpidersTable, @SpidersPos) <> "none") {
#SAY Assigned $code to %item( @SpidersTable, @SpidersPos)
#ALIAS %item( @SpidersTable, @SpidersPos) {fade $code} {FadeScript|FadeAliases}
}
#ADD SpidersPos 1
#IF (@SpidersPos > %numitems( @SpidersTable)) {#T- {FadeScript|Spiders}}
|
Basically I want @SpidersTable to be dynamic. I have another variable called @FadeRank that I want to append onto @SpidersTable when it is used. So it would be like @SpidersTable5 or @SpidersTable-5 if @FadeRank = 5, ect. I hope this makes sense. I tried @{@SpidersTable}FadeRank} and that didn't seem to work how I thought it would.
Any help would be great.
Thanks! |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Jan 02, 2009 6:52 pm |
You're missing an @.
@{@SpidersTable@FadeRank} |
|
|
|
whorn Wanderer
Joined: 04 May 2002 Posts: 52 Location: USA
|
Posted: Fri Jan 02, 2009 7:39 pm |
gamma_ray wrote: |
You're missing an @.
@{@SpidersTable@FadeRank} |
That didn't seem to work either. And after looking at it shouldn't it be something like:
@{LookupTable@FadeRank}
Since the end output I want is @LookupTable5? |
|
|
|
whorn Wanderer
Joined: 04 May 2002 Posts: 52 Location: USA
|
Posted: Fri Jan 02, 2009 8:29 pm |
Aha! @{LookupTable@FadeRank} was what I was looking for. I was having issues other places that was causing me problem. You helped point me in the right direction though. Thanks!
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jan 03, 2009 1:26 am |
If you want to have text AFTER the dynamic part of the variable name, you'll need to use an expression inside the {}s (or just the concat function) to join the two strings together. But what you have will work fine for this example.
|
|
|
|
whorn Wanderer
Joined: 04 May 2002 Posts: 52 Location: USA
|
Posted: Sat Jan 03, 2009 2:14 am |
This is what I finally ended up with:
Code: |
@{@{FadeLoc}_FadeTable_@FadeRank}
|
Thanksf or all the help :). |
|
|
|
|
|