Read the text file (exported by Excel book) using Lua and generate a Lua table. 📗 Lua Scripting (Rainmeter Docs)
A part of @Resources\Scripts\init.lua
Code:
local number_of_elements = 7------------------------------------------------------------------------------- Read the text file (output by Excel book) and generate an items table-- **UTF-8 encoded file or ANSI ONLY**---- @see Input and Output| https://www.lua.org/manual/5.1/manual.html#5.7-- @see Tables Tutorial | http://lua-users.org/wiki/TablesTutorial-----------------------------------------------------------------------------local function read_book_data(file_path) _items = {} local fh = io.open(file_path, 'r') if fh then local t for line in fh:lines() do if line:find('^%s*<01>') then t = {} for i=1, number_of_elements do table.insert(t, line:match(string.format('<%02d>(.-)</%02d>', i, i)) or '') end table.insert(_items, t) end end fh:close() endend------------------------------------------------------------------------------- Increase or Decrease item_index number by mouse wheel scrolling then call load_item()---- @param {number} d scrolling direction. `-1` scroll up, `1` scroll down.-- @example MouseScrollDownAction=[!CommandMeasure MeasureScript "background_scroll(1)"]-- MouseScrollUpAction=[!CommandMeasure MeasureScript "background_scroll(-1)"]---- @see Creating a "counter" or "loop" by jsmorley | https://forum.rainmeter.net/viewtopic.php?p=96827#p96827-----------------------------------------------------------------------------function background_scroll(d) if 0<#items then load_item((item_index + d - 1) % #items + 1) endend