After much head-scratching and trial & error, I think have got the "compat53"
library working but not the "utf8"
library in its current form ~ see later.
Below is the code that worked for me.
I had to put the loadrequire
function is needed to add the "compat53"
components to the global environment.
I plagiarized it from the compat53.module
code. Did you need anything like that to get it working?
Code: Select all
if _VERSION ~= "Lua 5.3" then -- loadrequire for "utf8" and "compat53" libraries
-- loadrequire code snippet goes here
-- handle exporting to global scope
local function extend_table(from, to)
if from ~= to then
for k,v in pairs(from) do
if type(v) == "table" and
type(to[k]) == "table" and
v ~= to[k] then
to[k] = v
utf8lib = loadrequire("utf8") -- Must be before compat53 otherwise does not load due to utf8 conflict?
local M = require("compat53")
extend_table( M, _G ) -- Export local M to global _G
end -- if _VERSION ~= "Lua 5.3"
Then the features mentioned in https://github.com/keplerproject/lua-compat-5.3
under What's implemented
worked and the Lua 5.3 functions appeared in the utf8, string, math & table libraries.
I tested a variety of Lua 5.3 functions as listed below and they all worked similarly in FH V6 and FH V7.
Is there anything else you particularly want tested?
However, I cannot get the "utf8"
library to work, not even in FH V7.
The only user guide I could find was C:\Program Files (x86)\Family Historian 7 beta\Program\Lua\utf8\README.md
But the utf8
table only includes the Lua 5.3 functions and none of the gmatch
, etc, functions.
So none of the utf8
examples in README.md work and simply say:
An error has occurred - plugin failed to complete
[string "C:\Users\Mike\AppData\Local\Temp\~fhC943.tmp"]:15: attempt to call a nil value (field 'gmatch')
After a lot of digging around and more trial & error, I have found two problems with the utf8.lua
Firstly, in FH V7 Lua 5.3 the unpack
function is undefined and needs to be table.unpack
However, for FH V6 Lua 5.1 it needs to remain as unpack
So it needs if _VERSION == "Lua 5.3" then unpack = table.unpack end
near line 80.
Secondly, naming the module utf8.lua
and using a local utf8
table conflicts with the Lua utf8
So the module should be named utf-8.lua
and some other table such as local utfx
local utfx = require("utf-8")
then works correctly and functions like utfx.gmatch
Attached is my test script including iup.GetParam button demonstration and notes at end about Plugin Store Help page access.
I ask myself: Why am I spending my time debugging Calico Pie software?