**@Resources\SI.lua**:

Code: Select all

```
function SI(section, occurrence, formula)
local indexes = {}
for index in section:gmatch('%d+') do table.insert(indexes, index) end
if occurrence == 'first' then occurrence = 1 elseif occurrence == 'last' then occurrence = #indexes end
return tostring(SKIN:ParseFormula(string.gsub(formula, '<x>', tostring(indexes[tonumber(occurrence)] or '0')))) or '0'
end
```

**[SkinFolder]\SI.ini**:

Code: Select all

```
[Variables]
; Lua Way - Inline method:
; [&SI:SI('[#CURRENTSECTION]','last','(<x>)')]
; Old Way - Splits method:
G=[&SI:SI('
I=','last','(<x>)')]
; New Way - Buffer method:
V=!SetVariable X
P=[&SI:SI('[#*CURRENTSECTION*]','last','(<x>)')]
B=[&SI:SI('[#*X*]','last','(<x>)')]
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
---Measures---
[SI]
Measure=Script
ScriptFile=#@#SI.lua
UpdateDivider=-1
DynamicVariables=1
; Variables = 0 chars, Measures = 450 chars, Total = 450 chars
[LuaMeasureBlah7Blah15Blah3]
Measure=Calc
Formula=([&SI:SI('[#CURRENTSECTION]','last','(<x>)')])
UpdateDivider=-1
IfCondition=([&SI:SI('[#CURRENTSECTION]','last','(<x>)')]=3)
IfTrueAction=[!Log "Last index of [#CURRENTSECTION] (i.e. [&SI:SI('[#CURRENTSECTION]','last','(<x>)')]) equals 3"]
IfFalseAction=[!Log "Last index of [#CURRENTSECTION] (i.e. [&SI:SI('[#CURRENTSECTION]','last','(<x>)')]) equals 3"]
IfConditionMode=1
DynamicVariables=1
; Variables = 33 chars, Measures = 374 chars, Total = 407 chars
[OldMeasureBlah7Blah15Blah3]
Measure=Calc
Formula=([#G][#CURRENTSECTION][#I])
UpdateDivider=-1
IfCondition=([#G][#CURRENTSECTION][#I]=3)
IfTrueAction=[!Log "Last index of [#CURRENTSECTION] (i.e. [#G][#CURRENTSECTION][#I]) equals 3"]
IfFalseAction=[!Log "Last index of [#CURRENTSECTION] (i.e. [#G][#CURRENTSECTION][#I]) equals 3"]
IfConditionMode=1
DynamicVariables=1
; Variables = 103 chars, Measures = 310 chars, Total = 413 chars
[NewMeasureBlah7Blah15Blah3]
Measure=Calc
Formula=([#P])
UpdateDivider=-1
IfCondition=([#P]=3)
IfTrueAction=[#V# [#CURRENTSECTION]][!Log "Last index of [#X] (i.e. [#B]) equals 3"]
IfFalseAction=[#V# [#CURRENTSECTION]][!Log "Last index of [#X] (i.e. [#B]) equals 3"]
IfConditionMode=1
DynamicVariables=1
---Meters---
[MeterResult]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=LuaMeasureBlah7Blah15Blah3
MeasureName2=OldMeasureBlah7Blah15Blah3
MeasureName3=NewMeasureBlah7Blah15Blah3
Text="Results:#CRLF#Lua method = %1#CRLF#Old method = %2#CRLF#New method = %3"
DynamicVariables=1
```

Working Methods Comparison.jpg

I reduced things to either 1 or 2 capital letters, in order to be fair with every approach that works.

The Total Chars value indicates the winner.

If it's not enough, here's something you probably didn't anticipate: you can't use the

!SetVariable bang in regular measure options, like

Formula and such, so you must create another variable to set things up there the "plain" (aka P) way, while in bangs you must use your "bang" (aka B) way, along with setting the "variable" (aka V) holding the current section. This reduces the chars needed for the measure / meter (by the way, I didn't use your buffer approach in the meter yet), but increases the chars needed for the variables, not to mention it can create confusion between the P and B ways, along with requiring creating new variables for hypothetical arbitrary section names (other than the current section) you might want to get the index from. Well, in your buffer approach' defense, you only need to create / write those variable once, but then, so needs my split approach too, and only for changes in the occurrence or index formula (unless I split the #I# further, that is).

This is how simplifying things becomes complicating them, when one doesn't have all the tools working.

It's possible that your code will become like my regexes you quoted in another thread, and then it will be my time to meme your ways...