It is currently March 28th, 2024, 11:20 am

INI Concatenation Tool

Skins that control functions in Windows or Rainmeter
Post Reply
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

INI Concatenation Tool

Post by raiguard »

(This is a tool to aid with the development of other Rainmeter skins. I'm not sure if it belongs in this subforum, but I couldn't find a more likely subforum in which to place it, so here I am).

By far the most annoying thing about Rainmeter is the inability to dynamically create or destroy meters and measures. Often you will find yourself copy/pasting the same chunk of code over and over again, just changing a few things for every iteration (a disk letter, CPU core number, etc.). This tool automates this process, allowing rapid iteration and on-the-fly changes to large chunks of repeating code at once.

Using the Tool
To use the tool, first you must load the Concat.ini Rainmeter skin. Then click Edit Template. This will open the template file in your text editor.

The example template looks like this:

Code: Select all

[DummyMeasure^1^]
Measure=Calc
Formula=(OtherDummyMeasure^1^ / ^2^) % ^3^
IfMatch=Disk^4^:
IfMatchAction=[!Log "Disk ^4^: is enabled? Dummy log!"]
Disabled=#disable^1^#


(This code is obviously non-functional, and only serves to demonstrate how the tool works.)

For the template, you insert all of the code that you wish to have be repeated. For every instance of a block of text that you wish to have different between iterations (for example, core numbers, or disk drive letters), replace that block of text with a concat identifier string. These strings are formatted as ^number^, and correspond to tables that you will define shortly.

If you wish to have an empty line between iterations of the template, you must leave two empty lines at the end of the template.

Once you are finished with the template, click the Edit Tables button in the skin. This file will contain several tables that will be used to iterate different versions of the template. It may look something like this:

Code: Select all

AddTable('numerical', 1, 26) -- ^1^
AddTable('numerical', 32, 7) -- ^2^
AddTable('custom', { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }) -- ^3^
AddTable('alphabetical') -- ^4^
There are four different kinds of tables you can add:

Numerical | AddTable('numerical', start, finish)
Numerical tables are the simplest: they will simply iterate over every integer between the start and finish values you define (inclusive). If you wish to go backwards (decreasing instead of increasing), simply have the start value be larger than the finish value.

Alphabetical | AddTable('alphabetical')
This type will iterate over every letter of the alphabet.

RevAlphabetical | AddTable('revAlphabetical')
Same as alphabetical, but will start at Z and work backwards.

Custom | AddTable('custom', { 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 22, 01893753 })
This type simply allows you to define a custom table with any combination of strings and numbers.

The order you place these tables matters: their order in the tables file determines which identifier string will be associated with them. For example, when the script concatenates, all instances of ^4^ in the template will be associated with the alphabetical table we created.

After we save both the template and tables, we refresh (middle-click) the concat skin, then click Concatenate. After clicking it, we can then open the output file. The sample template and tables will output this result:

Code: Select all

[DummyMeasure1]
Measure=Calc
Formula=(OtherDummyMeasure1 / 32) % 1
IfMatch=DiskA:
IfMatchAction=[!Log "Disk A: is enabled? Dummy log!"]
Disabled=#disable1#

[DummyMeasure2]
Measure=Calc
Formula=(OtherDummyMeasure2 / 31) % 2
IfMatch=DiskB:
IfMatchAction=[!Log "Disk B: is enabled? Dummy log!"]
Disabled=#disable2#

[DummyMeasure3]
Measure=Calc
Formula=(OtherDummyMeasure3 / 30) % 1
IfMatch=DiskC:
IfMatchAction=[!Log "Disk C: is enabled? Dummy log!"]
Disabled=#disable3#

[DummyMeasure4]
Measure=Calc
Formula=(OtherDummyMeasure4 / 29) % 2
IfMatch=DiskD:
IfMatchAction=[!Log "Disk D: is enabled? Dummy log!"]
Disabled=#disable4#

[DummyMeasure5]
Measure=Calc
Formula=(OtherDummyMeasure5 / 28) % 1
IfMatch=DiskE:
IfMatchAction=[!Log "Disk E: is enabled? Dummy log!"]
Disabled=#disable5#

[DummyMeasure6]
Measure=Calc
Formula=(OtherDummyMeasure6 / 27) % 2
IfMatch=DiskF:
IfMatchAction=[!Log "Disk F: is enabled? Dummy log!"]
Disabled=#disable6#

[DummyMeasure7]
Measure=Calc
Formula=(OtherDummyMeasure7 / 26) % 1
IfMatch=DiskG:
IfMatchAction=[!Log "Disk G: is enabled? Dummy log!"]
Disabled=#disable7#

[DummyMeasure8]
Measure=Calc
Formula=(OtherDummyMeasure8 / 25) % 2
IfMatch=DiskH:
IfMatchAction=[!Log "Disk H: is enabled? Dummy log!"]
Disabled=#disable8#

[DummyMeasure9]
Measure=Calc
Formula=(OtherDummyMeasure9 / 24) % 1
IfMatch=DiskI:
IfMatchAction=[!Log "Disk I: is enabled? Dummy log!"]
Disabled=#disable9#

[DummyMeasure10]
Measure=Calc
Formula=(OtherDummyMeasure10 / 23) % 2
IfMatch=DiskJ:
IfMatchAction=[!Log "Disk J: is enabled? Dummy log!"]
Disabled=#disable10#

[DummyMeasure11]
Measure=Calc
Formula=(OtherDummyMeasure11 / 22) % 1
IfMatch=DiskK:
IfMatchAction=[!Log "Disk K: is enabled? Dummy log!"]
Disabled=#disable11#

[DummyMeasure12]
Measure=Calc
Formula=(OtherDummyMeasure12 / 21) % 2
IfMatch=DiskL:
IfMatchAction=[!Log "Disk L: is enabled? Dummy log!"]
Disabled=#disable12#

[DummyMeasure13]
Measure=Calc
Formula=(OtherDummyMeasure13 / 20) % 1
IfMatch=DiskM:
IfMatchAction=[!Log "Disk M: is enabled? Dummy log!"]
Disabled=#disable13#

[DummyMeasure14]
Measure=Calc
Formula=(OtherDummyMeasure14 / 19) % 2
IfMatch=DiskN:
IfMatchAction=[!Log "Disk N: is enabled? Dummy log!"]
Disabled=#disable14#

[DummyMeasure15]
Measure=Calc
Formula=(OtherDummyMeasure15 / 18) % 1
IfMatch=DiskO:
IfMatchAction=[!Log "Disk O: is enabled? Dummy log!"]
Disabled=#disable15#

[DummyMeasure16]
Measure=Calc
Formula=(OtherDummyMeasure16 / 17) % 2
IfMatch=DiskP:
IfMatchAction=[!Log "Disk P: is enabled? Dummy log!"]
Disabled=#disable16#

[DummyMeasure17]
Measure=Calc
Formula=(OtherDummyMeasure17 / 16) % 1
IfMatch=DiskQ:
IfMatchAction=[!Log "Disk Q: is enabled? Dummy log!"]
Disabled=#disable17#

[DummyMeasure18]
Measure=Calc
Formula=(OtherDummyMeasure18 / 15) % 2
IfMatch=DiskR:
IfMatchAction=[!Log "Disk R: is enabled? Dummy log!"]
Disabled=#disable18#

[DummyMeasure19]
Measure=Calc
Formula=(OtherDummyMeasure19 / 14) % 1
IfMatch=DiskS:
IfMatchAction=[!Log "Disk S: is enabled? Dummy log!"]
Disabled=#disable19#

[DummyMeasure20]
Measure=Calc
Formula=(OtherDummyMeasure20 / 13) % 2
IfMatch=DiskT:
IfMatchAction=[!Log "Disk T: is enabled? Dummy log!"]
Disabled=#disable20#

[DummyMeasure21]
Measure=Calc
Formula=(OtherDummyMeasure21 / 12) % 1
IfMatch=DiskU:
IfMatchAction=[!Log "Disk U: is enabled? Dummy log!"]
Disabled=#disable21#

[DummyMeasure22]
Measure=Calc
Formula=(OtherDummyMeasure22 / 11) % 2
IfMatch=DiskV:
IfMatchAction=[!Log "Disk V: is enabled? Dummy log!"]
Disabled=#disable22#

[DummyMeasure23]
Measure=Calc
Formula=(OtherDummyMeasure23 / 10) % 1
IfMatch=DiskW:
IfMatchAction=[!Log "Disk W: is enabled? Dummy log!"]
Disabled=#disable23#

[DummyMeasure24]
Measure=Calc
Formula=(OtherDummyMeasure24 / 9) % 2
IfMatch=DiskX:
IfMatchAction=[!Log "Disk X: is enabled? Dummy log!"]
Disabled=#disable24#

[DummyMeasure25]
Measure=Calc
Formula=(OtherDummyMeasure25 / 8) % 1
IfMatch=DiskY:
IfMatchAction=[!Log "Disk Y: is enabled? Dummy log!"]
Disabled=#disable25#

[DummyMeasure26]
Measure=Calc
Formula=(OtherDummyMeasure26 / 7) % 2
IfMatch=DiskZ:
IfMatchAction=[!Log "Disk Z: is enabled? Dummy log!"]
Disabled=#disable26#
A Real-World Example
To show you this tool in action, I created this video of me using the tool to iterate on Disks Meter's disk measures and meters:



Anyway, I hope that the Rainmeter community can get some use out of this tool. I am not known for my eloquence in explaining complicated things, so if my explanation was complete gobsmack to you, please let me know and I'll do my best to try to explain clearly. Happy skinning!

TL;DR
This tool lets you make changes to large portions of repeating code at once, using a template and a few data tables. See the video above for an example of how it can be used.
Attachments
INI Concatenation Tool_1.0.0.rmskin
(112.34 KiB) Downloaded 99 times
Last edited by raiguard on January 29th, 2019, 10:03 pm, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: INI Concatenation Tool

Post by eclectic-tech »

tl;dr :D

Definitely going to try it out!

Nice work! :thumbup:
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

Re: INI Concatenation Tool

Post by raiguard »

eclectic-tech wrote: January 29th, 2019, 1:35 pm tl;dr :D
Yeah, I was a bit tired when I wrote this. I went back and cleaned up some unnecessary fluff, and made a TLDR. :D
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany
Contact:

Re: INI Concatenation Tool

Post by Active Colors »

Very nice workaround and solution. Personally, not a fan of copypasting, wish Rainmeter was just a bit more template based.
User avatar
LGP123
Posts: 60
Joined: November 5th, 2016, 12:15 pm

Re: INI Concatenation Tool

Post by LGP123 »

I made a similar tool for myself long ago but yours seems more convenient and more powerfull. I'll be sure to try it! :welcome:
Post Reply