|
wth Novice
Joined: 14 Nov 2001 Posts: 37 Location: Poland
|
Posted: Thu Jun 27, 2002 9:45 pm
Parameters scope in triggers? |
#TEMP {foo (*)} {
#VARIABLE tmp "aaa|bbb|ccc|ddd|eee"
#FORALL @tmp {
#SAY %1
}
}
In FORALL loop parameter %1 is from #TEMP parameter not #FORALL - how to make %1 get values from list?
Rgds,
--
Waldek
There are no mistakes, just learning experience |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Thu Jun 27, 2002 9:50 pm |
#LOOP, #FORALL use the tracking variable %i. So you would want:
#TEMP {foo (*)} { #VARIABLE tmp "aaa|bbb|ccc|ddd|eee";#FORALL @tmp { #SAY %i }}
If you have loops in loops etc, you would have to save the
previous %i
#LOOP 2 {
#VAR FirstLoop_i %i
#LOOP 2 {
#ECHO First loop: @FirstLoop_i Second Loop: %i
}
}
Ton Diening
Providing untested answers that tend to be
more complicated than others. |
|
|
|
wth Novice
Joined: 14 Nov 2001 Posts: 37 Location: Poland
|
Posted: Thu Jun 27, 2002 11:26 pm |
You didnt understand my problem. In my case #SAY %1 won't output 'aaa', but will output 5 times string which triggered trigger (string from (*)).
So in my case %1 is not scoped from #FORALL but is scoped from #TEMP trigger - something wrong!?
PS. I'm proffesional developer and know many programing languages - zMud is only one script language which I know, but sometimes works, ekhm... strange
Best rgds,
--
Waldek
There are no mistakes, just learning experience |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Thu Jun 27, 2002 11:32 pm |
That is because %1..%n is used to refer to values matched by the pattern of the trigger and that zMUD stores because you told it to do it. If you look at Ton's reply, you'll see that inside the #FORALL loop you need to use %i not %1 to refer to the current iteration. That is, it's:
#VARIABLE tmp "aaa|bbb|ccc|ddd|eee"
#FORALL @tmp {#SAY %i}
not:
#VARIABLE tmp "aaa|bbb|ccc|ddd|eee"
#FORALL @tmp {#SAY %1}
no matter if it is all by itself or inside a trigger/alias/macro/etc.
Kjata |
|
|
|
wth Novice
Joined: 14 Nov 2001 Posts: 37 Location: Poland
|
Posted: Thu Jun 27, 2002 11:38 pm |
Yes - sorry for problem - I've just found this error by myself.
I'm using temp trigger in alias so each parameter I have to write as %%1 or %%i and this little embarassed me.
Now everything is ok.
Rgds,
--
Waldek
There are no mistakes, just learning experience |
|
|
|
|
|