Sales.txt
Code: Select all
<machinesales target="100000" actual="6500" projected="250000"/>
<aftermarketsales target="50000" actual="10000" projected="60000"/>
<repairsales target="50000" actual="10000" projected="60000"/>
Code: Select all
function Initialize()
sFileName = SKIN:MakePathAbsolute(SELF:GetOption('FileName'))
mtPrefix = SELF:GetOption('MeterPrefix','mt')
end -- Initialize
function Update()
hFile = io.open(sFileName)
if not io.type(hFile)=='file' then
print('File error')
return 'File error'
else
local text=io.read('*all')
io.close(hFile)
for tag,contents in string.gmatch(text,'<([^%s>]+)(.-)%/>') do
local tbl={target=0,actual=0,projected=1}
for key,value in string.gmatch(contents,'(%a+)=(%b"")') do
local strip=string.match(value,'"(.+)"')
tbl[string.lower(strip)]=tonumber(strip) or strip
end
local mHandle=SKIN:GetMeter(mtPrefix..string.lower(tag))
local MeasureName=mHandle:GetOption('MeasureName')
if SKIN:GetMeasure(MeasureName) then
SKIN:Bang('!SetOption',MeasureName,'Formula',tbl.actual)
end
end
end
end -- Update
Code: Select all
[Lua]
Measure=Script
ScriptFile=Lua.lua
FileName=Sales.Txt
Update=-1
Now, to get this to work we need to set up our meters with their measure pairs.
Code: Select all
[msOne]
Measure=Calc
Formula=0
MaxValue=500000
[mtmachinesales]
Meter=Roundline
MeasureName=msOne
Blah...
Blah...
You Know The Rest
What the measures are currently being set to is the actual sales figure present in the text file.
NOTE: I am not able to test this as the moment.