I've created a KnowledgeBase article on Writing Plugins Compatible with Versions 5, 6 & 7 if anyone would care to review it.
It's not intended to be exhaustive, but to cover the points that many plugin authors will come across and provide advice for how to tackle less common scenarios.
* Writing Plugins Compatible with Versions 5, 6 & 7
- ColeValleyGirl
- Megastar
- Posts: 4853
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
- tatewise
- Megastar
- Posts: 27082
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Writing Plugins Compatible with Versions 5, 6 & 7
Looks reasonably comprehensive.
I think the body of function table.getn(t) can simply be return #t
Regarding other Lua changes, is it worth mentioning the formatting of numbers.
i.e. string.format("%d",number) won't work if number is not an integer.
It needs string.format("%d",math.floor(number)) or similar to ensure the parameter is an integer.
That solution works for all Lua versions.
The iup.SetGlobal("CUSTOMQUITMESSAGE","YES") seems OK in all IUP versions so doesn't need to be conditional.
Regarding IUP a popular simple dialogue involves iup.GetParam(..) but a bug prevents the button labels being changed from OK and Cancel. The workaround is:
and to add a Help button:
I think the body of function table.getn(t) can simply be return #t
Code: Select all
function table.getn(t)
return #t
end
i.e. string.format("%d",number) won't work if number is not an integer.
It needs string.format("%d",math.floor(number)) or similar to ensure the parameter is an integer.
That solution works for all Lua versions.
The iup.SetGlobal("CUSTOMQUITMESSAGE","YES") seems OK in all IUP versions so doesn't need to be conditional.
Regarding IUP a popular simple dialogue involves iup.GetParam(..) but a bug prevents the button labels being changed from OK and Cancel. The workaround is:
Code: Select all
function paramAction(iupDialog,intIndex)
if intIndex == iup.GETPARAM_MAP then -- Correct button labels needed for IUP 3.28 bug
iupDialog.Button1.Title = "Edit" -- Otherwise remain as OK and Cancel
iupDialog.Button2.Title = "Exit"
end
return 1
end
local isAns,strAns = iup.GetParam("Test",paramAction,"%u[Edit,Exit]") -- Displays dialogue with buttons Edit and Exit
Code: Select all
function paramAction(iupDialog,intIndex)
if intIndex == iup.GETPARAM_MAP then -- Correct button labels needed for IUP 3.28 bug
iupDialog.Button1.Title = "Apply Rules"
iupDialog.Button2.Title = "Cancel Plugin"
elseif intIndex == (iup.GETPARAM_HELP or -4) then -- FH V5 needs -4
fhShellExecute("https://pluginstore.family-historian.co.uk/page/help/main-help-page","","","open")
end
return 1
end -- function paramAction
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry