| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Message
| What happens is that when you send to script, with expand variables checked, it first simply replaces each variable in this text:
SetVariable ("brewamt" , %1 * 5)
SetVariable ("brewamt2" , @brewamt * 2)
SetVariable ("brewtype", "%2")
ColourNote ("white", "black", "@brewamt, @brewamt2, @brewtype")
SetStatus ("@brewamt, @brewamt2, @brewtype")
... with the variable contents. So for example, if (before it executes) brewamt is "10", brewamt2 is "20", and brewtype is "health" then you will get:
SetVariable ("brewamt" , %1 * 5)
SetVariable ("brewamt2" , 10 * 2)
SetVariable ("brewtype", "%2")
ColourNote ("white", "black", "10, 20, health")
SetStatus ("10, 20, health")
That's before it gets your wildcards. It is before the script executes. Then the script executes. It's too late to use the variables you set inside the script like that.
The simple fix is to keep using the wildcards, eg.
SetVariable ("brewamt" , %1 * 5)
SetVariable ("brewamt2" , @brewamt * 2)
SetVariable ("brewtype", "%2")
ColourNote ("white", "black", %1 * 5 .. ", " .. %1 * 10 .. ", " .. %2)
SetStatus (%1 * 5 .. ", " .. %1 * 10 .. ", " .. %2)
Are you using these variables anywhere else? If not, there is no real point in setting them. Also you can use GetVariable, because this works:
SetVariable ("brewtype" , "%2")
ColourNote ("white", "black", "Brew type now: " .. GetVariable ("brewtype"))
That works because GetVariable executes as part of the script, and gets back the variable you just set.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|