 |
rythin Beginner
Joined: 12 Jul 2011 Posts: 13
|
Posted: Sun Oct 02, 2011 11:57 am
Creating dynamic triggers/subs. |
Hi!
I want an alias that will dynamically create a bunch of trigger/substitutes, something along these lines:
#alias Test1 {
#repeat %numitems(@List1) {
Temp1=List1.%i
Temp2=List2.%i
#trigger @List1.%i @List1.%i {#sub @Temp1 @Temp2} {ClassName}
}
}
So, for example, List1="big dwarf", List2="Tony", whenever I encounter big dwarf I want to sub him into big dwarf Tony. It indeed creates a trigger with a pattern of "big dwarf", but an action is "#sub @Temp1 @Temp2", while I want it to be "#sub big dwarf Tony". How do I do that?
Thanks in advance,
r. |
|
|
 |
geniusclown Magician

Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Sun Oct 02, 2011 12:37 pm |
I had a similar problem working with #GAUGE not long ago that was solved by using #EXEC %concat(). Thus:
Code: |
#EXEC %concat("#trigger ",@List1.%i," ",@List1.%i," {#sub ",@Temp1," ",@Temp2"} {ClassName}") |
I ran into troubles because I had parenthesis in the quotes and it messed with the parser, so I had to use %char() for those... if the parser doesn't like the braces, for example, you can do #ECHO %ascii("{") from the command line to discover that the ascii code for open brace is 123, and put %char(123) into the %concat line above. (You can, of course, just use any ascii chart for the numerical equivalences, but it's much easier imho to just use the tools at hand.) |
|
_________________ .geniusclown |
|
|
 |
rythin Beginner
Joined: 12 Jul 2011 Posts: 13
|
Posted: Sun Oct 02, 2011 1:31 pm |
Splendid! It works perfectly. Thank you!
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|