Hello Guys,
Rainmeter gives "Script: File not valid" for the following LUA Script and I can't find an error.
The script should read a text file line by line in which data records are created line by line, similar to a CSV file, except that the separator is a "~" (see at the end).
When a skin element is clicked, the variable cng_Value is set with the new value and cng_Field with the field to be changed like "z2_s5" (z=Zeile/Row,s=Spalte/Column --> Row 2 - Column 5). The script should replace cng_Value in the row/column with the value of cng_Field (row/column). Afterwards, all data records in the array are written back to the file, including the changed data.
The skin should issue daily reminders for certain events.
Could someone find the error please?
alt_line.lua:dayly_todo.txt:
Rainmeter gives "Script: File not valid" for the following LUA Script and I can't find an error.
The script should read a text file line by line in which data records are created line by line, similar to a CSV file, except that the separator is a "~" (see at the end).
When a skin element is clicked, the variable cng_Value is set with the new value and cng_Field with the field to be changed like "z2_s5" (z=Zeile/Row,s=Spalte/Column --> Row 2 - Column 5). The script should replace cng_Value in the row/column with the value of cng_Field (row/column). Afterwards, all data records in the array are written back to the file, including the changed data.
The skin should issue daily reminders for certain events.
Could someone find the error please?
alt_line.lua:
Code:
local cng_Value = SKIN:GetVariable('cng_Value')local z_s_cng= SKIN:GetVariable('cng_Field')local z_cng = tonumber(string.match(z_s_cng, "z(.-)_"))local s_cng = tonumber(string.match(z_s_cng, "s(.*)$"))-- File pathlocal file = "dayly_todo.txt"local base_dir = SKIN:GetVariable('path')local file_path = base_dir .. file-- Open file in read-write modelocal read_file = io.open(file_path, "w")-- reads file in an arraylocal zeilen = {}if read_file then for line in read_file:lines() do -- Read file line by line and store the lines in an array local einzelwerte = {} for wert in line:gmatch("[^~]+") do table.insert(einzelwerte, wert) -- Insert the individual values into the inner array end table.insert(zeilen, einzelwerte) -- Insert the array of single values into the main array endend--Initialize data variablelocal data = ""-- write the lines including changed data into the variable datafor z, einzelwerte in ipairs(zeilen) do for s, wert in ipairs(einzelwerte) do if s == s_cng and z == z_cng then data = data .. "~" .. cng_Value -- writes the changed value it in the line else data = data .. "~" .. wert --writes the previous value into the line end end data = string.sub(data, 1, -2) -- Removes the last character ~ data = data .. "\n" -- adds a line break at the end of the lineendif write_file then write_file:write(data) -- Write the variable data into the fileendwrite_file:close() -- Close fileSKIN:Bang('!Refresh')
Code:
ASS 100~1~1~1~1~1~1~1~6:30Rosuvastatin~1~1~1~1~1~1~1~6:30Pantoprazol (1h v Essen)~1~1~1~1~1~1~1~17:00Vit. D+K~0~0~0~0~0~0~1~10:00
Statistics: Posted by ⦿⽘⦿ — September 21st, 2024, 9:59 pm