Does that make sense?
I think so. I would look at something like this:
Skin:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
NumRows=0
[Lua]
Measure=Script
ScriptFile=Test.lua
Disabled=1
[MeterBackground]
Meter=Shape
Shape=Rectangle 1,1,200,([&MeterField[#NumRows]:Y] + [&MeterField[#NumRows]:H] + 10) | StrokeWidth 1 | StrokeColor 255,255,255,255 | Fill Color 47,47,47,255
DynamicVariables=1
[MeterField1]
Meter=String
Group=Group1
X=10
Y=10
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
DynamicVariables=1
Hidden=1
Text=[&Lua:GetField(1,'nameField1')]
[MeterField2]
Meter=String
Group=Group2
X=0r
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
DynamicVariables=1
Hidden=1
Text=[&Lua:GetField(2,'nameField1')]
[MeterField3]
Meter=String
Group=Group3
X=0r
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
DynamicVariables=1
Hidden=1
Text=[&Lua:GetField(3,'nameField1')]
[MeterField4]
Meter=String
Group=Group4
X=0r
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
DynamicVariables=1
Hidden=1
Text=[&Lua:GetField(4,'nameField1')]
[MeterField5]
Meter=String
Group=Group5
X=0r
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
DynamicVariables=1
Hidden=1
Text=[&Lua:GetField(5,'nameField1')]
Test.lua:
Code: Select all
function Initialize()
FilePath = SKIN:MakePathAbsolute("myCSV.csv")
arrayList = {}
for line in io.lines(FilePath) do
numberField1, nameField1, typeField1, nameField2, nameField3, dateField1, dateField2, dateField3, dateField4, answerField1 = line:match('%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-),%s*(.-)$')
arrayList[#arrayList + 1] = { numberField1=numberField1, nameField1=nameField1, typeField1=typeField1, nameField2=nameField2, nameField3=nameField3, dateField1=dateField1, dateField2=dateField2, dateField3=dateField3, dateField4=dateField4, answerField1=answerField1 }
end
SKIN:Bang('!SetVariable', 'NumRows', #arrayList)
end
function GetField(indexArg, fieldArg)
if indexArg <= #arrayList then
SKIN:Bang('!ShowMeterGroup', 'Group'..indexArg)
return arrayList[indexArg][fieldArg]
else
SKIN:Bang('!HideMeterGroup', 'Group'..indexArg)
return ''
end
end
myCSV.csv:
Code: Select all
01234,BobsBobShop,Service,Mike,Tim,2019/04/20,2019/05/20,N/A,2019/06/10,YES
05778,MikesMikeShop,Design&Build,John,Paul,2019/04/20,2019/05/20,,2019/06/10,YES
02487,BillsBillShop,Build,Tom,Tim,2019/03/10,N/A,2019/04/08,2019/06/10,NO
02147,TomsTomShop,Design,Eric,Tim,2019/04/20,2019/05/20,2019/06/10,N/A,NO
1.jpg
So the approach is to really not focus on how many rows there actually are in the array, but rather to just "hide" all the meters displaying them, and only if they exist in the array, then "show" them. To do this, we set them all with Hidden=1 to start with, and in the Lua script we either !ShowMeterGroup the group of meters associated with that single row, or !HideMeterGroup them. The "background" will use the position and height of the last visible meter in a (formula), along with 10 pixels of extra cosmetic space at the end, in a dynamic way to determine how big it should be.
So in this example, I am asking for 5 rows from the array, but there are currently only 4.
Note that I am simplifying things quite a bit by having consistent names for Groups and Meters so I can just append the indexArg number to them in the Lua to get a match.
The way I am building the height value in the Shape meter may not be entirely intuitive, as it does some pretty arcane "nesting" of section variables and regular variables. Check this out:
https://docs.rainmeter.net/manual/variables/section-variables/#MeterParameters
https://docs.rainmeter.net/manual/variables/nesting-variables/
As an aside, if the number of rows in the array can ever be "more" than the number of meters you have designed to show them, then you will want to check against some maxRows variable in the Lua, and set the NumRows variable accordingly.
You do not have the required permissions to view the files attached to this post.