It is currently March 28th, 2024, 5:54 pm

How to use SKIN:ParseFormula??

Discuss the use of Lua in Script measures.
Post Reply
soyelrafa
Posts: 96
Joined: March 1st, 2017, 3:09 pm

How to use SKIN:ParseFormula??

Post 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'))

Image

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.
Last edited by soyelrafa on August 8th, 2017, 1:10 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to use SKIN:ParseFormula??

Post 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'))

Image

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
soyelrafa
Posts: 96
Joined: March 1st, 2017, 3:09 pm

Re: How to use SKIN:ParseFormula??

Post by soyelrafa »

jsmorley wrote: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
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'))"
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to use SKIN:ParseFormula??

Post 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...
soyelrafa
Posts: 96
Joined: March 1st, 2017, 3:09 pm

Re: How to use SKIN:ParseFormula??

Post 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 :thumbup:
Post Reply