|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Mon Nov 05, 2007 7:18 pm
[2.10] Firing triggers |
I've ran into some strange situation with two triggers (with debug script like #SAY blah-blah-blah) gagging lines, but when I tried to narrow this I've found another strange thing
Enter this code in a new session
Code: |
#TRIGGER {1} {#SAY Trigger fires!} |
OR, if you want to test it with real variable, enter this:
Code: |
#VAR TestVar 0;#TRIGGER {@TestVar + 1} {#SAY Trigger fires!} |
Open the editor and change trigger type to Expression. Note that trigger fires.
Do not close the editor. Just click continuously on trigger tabs "Compiled Code", "Compiled Pattern" and note that trigger keeps firing. Actually, you can use any expression you want.
Btw, can anybody tell me how I can make a trigger on variable if variable can be =0 among other values? For now I use that silly (@Var + const) syntax I used in example. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Nov 05, 2007 7:37 pm |
Your expression 1 will never evaluate to false, so it's no surprise that it keeps firing. A similar thing is true for the second variable, but only when the value of TestVar is >=0 instead of >0.
For your second question, depending on the values in question, you can use > or >=. In the second case there, you can use >-1 or >=0, either works. |
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Mon Nov 05, 2007 7:55 pm |
For my first question: But why trigger fires while I switch tabs? Editor not only shows me information on trigger but execute it too? And in my example with variable - it value did not change, why the trigger keeps firing?
For my 2nd: bah, it soo simple after you know the answer... Thanks, Fang! I somehow forget about > or >= |
|
_________________ My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Nov 05, 2007 8:05 pm |
It's probably because the Compiled Code and Compiled Pattern tabs cause their respective items to be recompiled, which probably causes the trigger to be checked again, and thus fires it.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 05, 2007 8:06 pm |
Fang is correct. When you recompile an expression trigger it gets re-tested and will fire if the condition is true. This is normal.
|
|
|
|
|
|