|
tobei Newbie
Joined: 19 Mar 2004 Posts: 9 Location: Canada
|
Posted: Sat Apr 10, 2004 7:46 am
adding triggers from within aliases... |
Here is what i'm trying to do...
I type in qtsetup {You are here.} {Run away.} it does:
#var QT_Trig {%1}
#var QT_Action {%2}
I type in qtadd, it does:
#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format("&-32s", @QT_Trig)@QT_Action}} {QT}
The desired output would be:
#TRIGGER {You are here.} {#SUBSTITUTE {%format("&-32s", You are here.)Run away.}} {QT}
But instead i get this:
#TRIGGER {You are here.} {#SUBSTITUTE {%format("&-32s", @QT_Trig)@QT_Action}} {QT}
I don't get it.. Anyone got any suggestions? |
|
|
|
jessew Apprentice
Joined: 03 Mar 2003 Posts: 141
|
Posted: Sat Apr 10, 2004 7:56 am |
You left out the <>s to expand the variables on the command part of the trigger?
not sure if this is what you mean
#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format("&-32s", <@QT_Trig>)<@QT_Action>}} {QT}
Cheers Jesse |
|
|
|
tobei Newbie
Joined: 19 Mar 2004 Posts: 9 Location: Canada
|
Posted: Sat Apr 10, 2004 8:01 am |
#TRIGGER {You are here.} {#SUBSTITUTE %format( "&-32s", <@QT_Trig>)<@QT_Action>}} {QT}
is the output
for some reason its not expanding the variables when its performing the #TRIGGER... |
|
|
|
tobei Newbie
Joined: 19 Mar 2004 Posts: 9 Location: Canada
|
Posted: Sat Apr 10, 2004 8:10 am |
Here is what I have right now...
#ALIAS qtsetup {#VARIABLE QT_Trig {%1};#VARIABLE QT_Action {%2}}
#ALIAS qtadd {#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format( "&-31s", @QT_Trig)" "@QT_Action}} {QT}}
The output is..
#TRIGGER {You are here.} {#SUBSTITUTE {%format( "&-31s", @QT_Trig)" "@QT_Action}} {QT}
I want it to look like:
#TRIGGER {You are here.} {#SUBSTITUTE {%format( "&-31s", You are here.) Run away.}} {QT}
As stated before.. just an update though... |
|
|
|
jessew Apprentice
Joined: 03 Mar 2003 Posts: 141
|
Posted: Sat Apr 10, 2004 9:45 am |
K, I misunderstood what you meant. The problem is #trigger doesnt parse variables till after the trigger is fired. And variables can be used in the pattern part as well so thats why there not being expanded.
But i came up with this dirty way of doing it, no doubt there is an easier way of doing this :P but it werks!
Uses concat to build the trigger line , allowing the variables to be expanded then executes the newly built trigger line
Code: |
#ALIAS qtadd {#exec %concat("#TRIGGER {", @QT_Trig,"} {#SUBSTITUTE {%format(~"&-31s~"~,",@QT_Trig,") ",@QT_Action,"}} {QT}")}
|
And unless there's a reason you need to do it with the variables it will be much easier just to do it like this:
Code: |
#alias qtadd {#TRIGGER {%1} {#substitute {%format("&-32s", %1) %2}} {QT}}
|
Cheers Jesse |
|
|
|
|
|