It is currently April 19th, 2024, 4:48 pm

code simplification

Get help with creating, editing & fixing problems with skins
Namus
Posts: 13
Joined: February 19th, 2011, 4:12 pm

code simplification

Post by Namus »

Hello :)

my rss reader in rainmeter use lots of repetitive items like "Meter 1-10" and "Measure 1-10" sharing almost same content
is there way how to simplify this huge number of lines? :)

example:

Code: Select all

[Measure1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Feed]
StringIndex=1
Substitute=#Substitute#
RegExpSubstitute=1

[Meter1]
Meter=STRING
MeterStyle=StyleItem
MeasureName=Measure1

[Measure2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Feed]
StringIndex=2
Substitute=#Substitute#
RegExpSubstitute=1

[Meter2]
Meter=STRING
MeterStyle=StyleItem
MeasureName=Measure2

...
thanks for any advice
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: code simplification

Post by jsmorley »

Not really. You are already using MeterStyle, which can eliminate a lot of repetitive meter options, but that is about all you can do to shorten this.
User avatar
AnimaliX
Posts: 33
Joined: August 22nd, 2016, 9:22 pm

Re: code simplification

Post by AnimaliX »

hello, any progress here? I mean that question is from 2014 and RM have active development.
I using "include" of course, but I prefer most simplified code for good maintenance and 20x Measure01-20 and Meter01-20 (webparsing rss) take over 4/5 of all lines in my skin :)
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: code simplification

Post by balala »

AnimaliX wrote: July 13th, 2020, 2:22 pm hello, any progress here? I mean that question is from 2014 and RM have active development.
As jsmorely said, there are still no solutions to this question. Rainmeter is definitely not a "de facto" programming language and this fact makes practically impossible to avoid repeating some sections, if they are needed.
But as far as I can tell, this is not a disadvantage. Rainmeter from start requires to create 10 measures, if 10 information are needed to be get and accordingly 10 meters in most cases, to show them. There is no easy other way to write the Rainmeter code. In some circumstances some lua scripts could help, but I doubt it worth. If you're working with Rainmeter skins, you have to take into account from the beginning the fact that some repetitions on code are needed.
Sorry...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5396
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: code simplification

Post by eclectic-tech »

AnimaliX wrote: July 13th, 2020, 2:22 pm hello, any progress here? I mean that question is from 2014 and RM have active development.
I using "include" of course, but I prefer most simplified code for good maintenance and 20x Measure01-20 and Meter01-20 (webparsing rss) take over 4/5 of all lines in my skin :)
Measure & Meter Templates can simplify this process.
User avatar
AnimaliX
Posts: 33
Joined: August 22nd, 2016, 9:22 pm

Re: code simplification

Post by AnimaliX »

thanks for the tip, and yes I am afraid that without some simple scripting this cant be done
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: code simplification

Post by balala »

AnimaliX wrote: July 13th, 2020, 6:21 pm thanks for the tip, and yes I am afraid that without some simple scripting this cant be done
But doesn't even have to. It's not the nature of Rainmeter, rather of a programming language (which, as said, Rainmeter isn't).
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: code simplification

Post by Active Colors »

jsmorley wrote: January 18th, 2014, 5:11 pm Not really. You are already using MeterStyle, which can eliminate a lot of repetitive meter options, but that is about all you can do to shorten this.
Any plans to introduce MeasureStyle, sooner or later?
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: code simplification

Post by Active Colors »

AnimaliX wrote: July 13th, 2020, 6:21 pm thanks for the tip, and yes I am afraid that without some simple scripting this cant be done
It is possible to do it . Can you send your example code?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5396
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: code simplification

Post by eclectic-tech »

AnimaliX wrote: July 13th, 2020, 6:21 pm thanks for the tip, and yes I am afraid that without some simple scripting this cant be done
Yes, not in native Rainmeter, but it can be easily accomplished using a template, and the Lua string:gsub function (as described by JSMorley) to replace 'incremental' values.