It is currently March 29th, 2024, 6:50 am

How to escape braces in plugin commands?

Get help with creating, editing & fixing problems with skins
spook
Posts: 7
Joined: September 9th, 2020, 2:07 pm

How to escape braces in plugin commands?

Post by spook »

I have the following code:

Code: Select all

[MeasureWeatherUpdater]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Wait 5000 | SetSource | UpdateTemperature | UpdateIcon | RedrawAll
(...)
UpdateIcon=[!SetOption "MeterIcon" "ImageName" #@#[MeasureJson:Query("current.weather[0].icon")].png][!UpdateMeter "MeterIcon"]
UpdateIcon action doesn't get executed. However if I replace "current.weather[0].icon" with "current.weather(0).icon", it works. I need square braces though. How can I escape them?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to escape braces in plugin commands?

Post by balala »

spook wrote: September 10th, 2020, 8:05 pm How can I escape them?
Please pack the whole config with the skin you're talking about and upload the package. I'd like to check, but for this is not enough the posted piece of code.
spook
Posts: 7
Joined: September 9th, 2020, 2:07 pm

Re: How to escape braces in plugin commands?

Post by spook »

The whole skin is on GitLab: https://gitlab.com/spook/Win10RainmeterSkin

I didn't create package yet. The skin requires my RainmeterJsonPlugin, which is on GitLab as well: https://gitlab.com/spook/RainmeterPlugins

The problematic skin is Weather.inc. I modified my plugin to use parenthesis, but nevertheless I'm interested on passing braces, because at some point I might not be able to modify the plugin and have to pass braces.

Try replacing:

Code: Select all

UpdateIcon=[!Log [MeasureJson:Query("current.weather(0).icon")]][!SetOption "MeterIcon" "ImageName" [MeasureJson:Query("current.weather(0).icon")]][!UpdateMeter "MeterIcon"]
with

Code: Select all

UpdateIcon=[!Log [MeasureJson:Query("current.weather[0].icon")]][!SetOption "MeterIcon" "ImageName" [MeasureJson:Query("current.weather(0).icon")]][!UpdateMeter "MeterIcon"]
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to escape braces in plugin commands?

Post by Yincognito »

spook wrote: September 10th, 2020, 8:05 pm I have the following code:

Code: Select all

[MeasureWeatherUpdater]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Wait 5000 | SetSource | UpdateTemperature | UpdateIcon | RedrawAll
(...)
UpdateIcon=[!SetOption "MeterIcon" "ImageName" #@#[MeasureJson:Query("current.weather[0].icon")].png][!UpdateMeter "MeterIcon"]
UpdateIcon action doesn't get executed. However if I replace "current.weather[0].icon" with "current.weather(0).icon", it works. I need square braces though. How can I escape them?
Probably not related, but the last parameter in the !SetOption should be enclosed between quotes as well. Try magic quotes (i.e. triple quotes) and see if it helps. You could also temporarily store the parameter as a String measure or a variable to see if it changes things for the better.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to escape braces in plugin commands?

Post by jsmorley »

"""Magic Quotes""" will solve the issue with the embedded quotes.

https://docs.rainmeter.net/manual/skins/option-types/#MagicQuotes

LeftMouseUpAction=[!Log """[MeasureJson:Query("current.weather[0].icon")]"""]

Note that this is only going to work in this instance if you DON'T actually have a measure named [0]. If you do, the action will resolve any and all variables in an order that always treats [MeasureName] as a section variable and will produce the value of the measure rather than the literal name.

If you DO have a measure named [0], you will also need to *escape* the section variable:

https://docs.rainmeter.net/manual/variables/#Escape

LeftMouseUpAction=[!Log """[MeasureJson:Query("current.weather[*0*].icon")]"""]

That will prevent Rainmeter from trying to resolve [0] to a value, and will treat it as a literal.

As long as you don't have an actual measure named [0], the square brackets are a non-issue. The embedded quotes in a parameter of a bang will ALWAYS be an issue, and must be addressed with Magic Quotes.