Due to an injury, I'm using a G13 to automate work tasks, one of which is entering the current date, in one of a few formats. Using the online compiler here: https://www.tutorialspoint.com/execute_lua_online.php, I was able to figure out how to get and format the date, but what I can't find is an output method that will send the string to Word, Chrome, Notepad, etc. - whatever the active window is. Outputting it to the log or LCD doesn't get it where I need it. Print doesn't output to the active window, and io.write gives the following error: [string "LuaVM"]:11: attempt to index global 'io' (a nil value). Os.date gave a similar error, that's why it's commented out.
My testbed code:
function OnEvent(event, arg)
OutputLogMessage("event = %s, arg = %s\n", event, arg)
local MKeyState = GetMKeyState("lhc")
--OutputLogMessage(MKeyState)
if (event == "G_PRESSED" and arg == 14 and MKeyState == 2) then
local date = GetDate("%m/%d/%y") --os.date("%m/%d/%y")
OutputLogMessage(date)
OutputLCDMessage(date)
io.write(date)
--print(os.date("%m/%d/%y"))
end
end
My testbed output:
event = PROFILE_DEACTIVATED, arg = 0
event = PROFILE_ACTIVATED, arg = 0
event = G_PRESSED, arg = 14
10/22/21[string "LuaVM"]:11: attempt to index global 'io' (a nil value)
event = G_RELEASED, arg = 14
Thanks in advance for any thoughts you might have.