|
apfinger Novice
Joined: 19 Nov 2006 Posts: 40
|
Posted: Sat Dec 30, 2006 11:08 pm
Setting one session's variable to an item from another array |
All of my sessions have a variable @Mob that I want to set using an array from one of the sessions.
One character has a variable called MobList and a variable called MobNumber. When I try this command:
:Mob = %item( @MobList, @MobNumber)
the current session sets the Mob variable appropriately, but the other sessions set Mob to an empty value. I'm assuming this is because the other sessions do not have access to MobList or MobNumber. How can I send the value of %item across to the other sessions?
In contrast to these results, I have an alias called MobIs which successfully sets the Mob variable for everyone.
:Mob = %1
Does anyone know how to resolve my issue? (other sessions not receive data from %item results)
Does anyone know why a wildcard appendage to an alias works, but using %item does not? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Dec 31, 2006 11:12 am |
The reason the alias works is because the %1 is expanded before the command is run, so the sessions don't see %1, they see the parameter you entered.
Try using <> or [] to cause the %item to be evaluated immediately. |
|
|
|
apfinger Novice
Joined: 19 Nov 2006 Posts: 40
|
Posted: Sun Dec 31, 2006 11:03 pm |
That explains why %1 works, thanks.
However, I tried your suggestion but was unable to resolve my issue.
:Mob = %item( @MobList, @MobNumber)
Here, Mob is set to an empty value
:Mob = <%item( @MobList, @MobNumber) >
Here, Mob is set to < > (empty value surrounded by < >)
:Mob = [%item( @MobList, @MobNumber)]
Here, I get syntax error
:Mob = %expand(%item( @MobList, @MobNumber)
Here, Mob is set to an empty value
:Mob = %expand(%item( @MobList, @MobNumber), 1)
Here, Mob is set to an empty value
:Mob = %expand(%item( @MobList, @MobNumber), -1)
Here, Mob is set to an empty value
I was unable to find documentation to properly explain the many uses of [ ] and < > in their entirety. Could someone point me in the right direction? Perhaps if I understood the purpose of these characters I could understand why I may have misused them in this situation. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Jan 02, 2007 10:58 am |
The correct way to do this is with #EXECUTE and #ALL
#EXECUTE {%concat("#ALL Mob=",%item(@MobList,@MobNumber))} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
apfinger Novice
Joined: 19 Nov 2006 Posts: 40
|
Posted: Wed Jan 03, 2007 3:10 am |
Winner!
I'll go read up on #EXECUTE, %concat, and #ALL to see why this statement interprets %item immediately rather than sending it to other sessions before interpreting.
Thanks! |
|
|
|
|
|