Variables Storing Formula

Posted by Traz on Wed 07 Mar 2018 01:45 AM — 2 posts, 10,682 views.

#0
So I'm trying to figure out how to store an equation in a variable for use in a single trigger, so I was playing with it in aliases to see how it works.

I can only seem to get it to work if I have two aliases, one that sets the variable, then another to call the variable.

Is there a way to do both in one alias/trigger?


<aliases>
  <alias
   match="test *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>test = "%1" + ("%1" * ".2")
SetVariable ("Test", test)</send>
  </alias>
  <alias
   match="test2"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>say @Test</send>
  </alias>
</aliases>
Australia Forum Administrator #1
Yes, you can do this:


test = "%1" + ("%1" * ".2")
SetVariable ("Test", test)
Send ("Say " .. GetVariable ("Test"))


Or even:


test = "%1" + ("%1" * ".2")
SetVariable ("Test", test)
Send ("Say " .. test)


What you can't do is this:



test = "%1" + ("%1" * ".2")
SetVariable ("Test", test)
Send ("Say @Test")


The reason for that is that @variables are expanded before the script starts executing, so that @Test will have its old value (if any) and changing the variable inside the script won't take effect until later.