|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sun May 06, 2007 10:05 pm
Did i do something stupid again? |
#ALIAS assassin {
$prof=assassin
#FORALL %replace(%params, " ", "|") {#ADDI $prof {%i}}
}
That should populate the @assassin variable right?
Thats what im trying to do, and it used to work, but now it doesn't. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon May 07, 2007 4:57 am |
I think you've got something confused.
If you are trying to assign the value of $prof to assassin you need to enter "assassin=$prof"; if you want to assign the value off assassin to the local variable $prof you need to enter "$prof=@assassin".
If assassin is just the text name then you may want to enter it in quotes "$prof='assassin'" |
|
_________________ Asati di tempari! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Mon May 07, 2007 7:45 am |
From the helpfile for #ADDI - Do not specify the @ before the name of the list variable.
the variable is @assassin, it only wants 'assassin' for the variable name
hence $prof=assassin
I guess this falls under indirect variable assignment |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon May 07, 2007 10:04 am |
I see what you're trying to do there but I don't believe in this case there is any incentive to use local variables I'm fairly certain it won't speed anything up.
Leave out the local variable assignment and just go with:
#ALIAS assassin {
#FORALL %replace(%params, " ", "|") {#ADDI assassin {%i}}
} |
|
_________________ Taz :) |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Mon May 07, 2007 11:23 am |
I tried something similar, where the $var was a parameter being passed in and the alias would let me add an item (or key) to the variable with the name stored in $var. I assume that's what this alias may have been trying to test. It can be done, but you have to use %additem or %addkey instead. Just using #ADDITEM $var {blah} will add the item to the local variable as a string list itself, and there is no way to force expansion of the $var to get the name passed to #ADDITEM as an argument.
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon May 07, 2007 7:00 pm |
Larkin,
Now that you mention it I believe there's a note somewhere around from Zugg that says local variable don't work with #ADDI and that the functions should be used. |
|
_________________ Asati di tempari! |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue May 08, 2007 1:44 am |
I know. It was in direct response to one of my threads, which is why I thought to mention it here. :)
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue May 08, 2007 2:20 am |
Local variable support for #ADDI, #ADDKEY, etc was added to one of the last couple of versions (forget exactly which one, but you can check the version history).
When using the command
#ADDITEM $var {blah}
it is adding "blah" as a string to the current string list contained in the $var local variable. There is no way to perform "indirect" variable addressing where $var contains another variable name.
I know this is what Larkin already said, but Tech's response makes it sound like "local variables don't work with #ADDI", which is incorrect. Local variables *do* work with #ADDI in the way that most people would expect them to work (most people are not doing indirect addressing). |
|
|
|
|
|