Page 1 of 1
How to use SKIN:ParseFormula??
Posted: August 8th, 2017, 11:56 am
by soyelrafa
Hello. I am trying to use the command SKIN:ParseFormula, but I can't get it to work.
I tried with the example of the lua scripting manual but it always prints 0:
print(SKIN:ParseFormula('2+2'))
I don't figure out what I am doing wrong...
The code is very simple:
Code: Select all
function Initialize()
print(SKIN:ParseFormula("2+2"))
end
function Update()
end
EDIT: I'm using 4.0.0 r2746 64-bit Rainmeter version.
Re: How to use SKIN:ParseFormula??
Posted: August 8th, 2017, 12:39 pm
by jsmorley
soyelrafa wrote:Hello. I am trying to use the command SKIN:ParseFormula, but I can't get it to work.
I tried with the example of the lua scripting manual but it always prints 0:
print(SKIN:ParseFormula('2+2'))
I don't figure out what I am doing wrong...
The code is very simple:
Code: Select all
function Initialize()
print(SKIN:ParseFormula("2+2"))
end
function Update()
end
EDIT: I'm using 4.0.0 r2746 64-bit Rainmeter version.
Remember that formulas in Rainmeter must be enclosed in (parentheses). The only exceptions are the Formula option of a Calc measure, and the test in an IfCondition.
Code: Select all
function Initialize()
print(SKIN:ParseFormula('(2+2)'))
end
function Update()
end
https://docs.rainmeter.net/manual/lua-scripting/#ParseFormula
Re: How to use SKIN:ParseFormula??
Posted: August 8th, 2017, 1:02 pm
by soyelrafa
Ah, okay, thanks for the info!!
Then I assume this part has an error? Or if you do with CommandMeasure are other exception to that effect?
Code: Select all
!CommandMeasure
The !CommandMeasure bang can be used to execute Lua code in the context of a particular script instance:
!CommandMeasure "MyScriptMeasure" "MyFunction()"
Multiple statements may be separated by semicolons (;). All statements are global.
!CommandMeasure "MyScriptMeasure" "a = b; print(SKIN:ParseFormula('2+2'))"
All statements must be passed as a single parameter in the bang. Because single-quotes (') and double-quotes (") are both valid string containers in Lua, while only double-quotes are recognized in Rainmeter, single quotes are recommended when passing strings with !CommandMeasure.
Concretely: !CommandMeasure "MyScriptMeasure" "a = b;
print(SKIN:ParseFormula('2+2'))"
Re: How to use SKIN:ParseFormula??
Posted: August 8th, 2017, 1:06 pm
by jsmorley
soyelrafa wrote:Ah, okay, thanks for the info!!
Then I assume this part has an error? Or if you do with CommandMeasure are other exception to that effect?
Code: Select all
!CommandMeasure
The !CommandMeasure bang can be used to execute Lua code in the context of a particular script instance:
!CommandMeasure "MyScriptMeasure" "MyFunction()"
Multiple statements may be separated by semicolons (;). All statements are global.
!CommandMeasure "MyScriptMeasure" "a = b; print(SKIN:ParseFormula('2+2'))"
All statements must be passed as a single parameter in the bang. Because single-quotes (') and double-quotes (") are both valid string containers in Lua, while only double-quotes are recognized in Rainmeter, single quotes are recommended when passing strings with !CommandMeasure.
Concretely: !CommandMeasure "MyScriptMeasure" "a = b;
print(SKIN:ParseFormula('2+2'))"
Yeah, that looks like an error in the documentation. I'll fix that...
Edit: Fixed...
Re: How to use SKIN:ParseFormula??
Posted: August 8th, 2017, 1:10 pm
by soyelrafa
jsmorley wrote:Yeah, that looks like an error in the documentation. I'll fix that...
Understood, thanks for your fast reply and for the answers