Converting homemade plugins to FH7
Posted: 12 Dec 2020 19:46
Hi all,
Just wanted to share...
Aside from changes in the new versions of lua and iup, I've discovered that changes to the GEDCOM structure also need to be taken into account.
For example, the structure for media objects (OBJE) has changed.
The following is code to add a media object for FH6
This is the new code for FH7
Also, it seems that fhSetValueAsText still works with note fields. It's not necessary to use fhSetValueAsRichText if you are not adding/updating a note which does not use RichText features.
Regards,
Shosh
Just wanted to share...
Aside from changes in the new versions of lua and iup, I've discovered that changes to the GEDCOM structure also need to be taken into account.
For example, the structure for media objects (OBJE) has changed.
The following is code to add a media object for FH6
Code: Select all
--------------------------------------------------------------------------------
-- AddMedia
--------------------------------------------------------------------------------
function AddMedia(pMediaPath, pMediaName, pMediaTitle, pFormat, pKeys, pSource)
ptrObje = fhCreateItem("OBJE")
if ptrObje:IsNotNull() then
local ptrTag = fhCreateItem("TITL",ptrObje,true)
fhSetValueAsText(ptrTag, pMediaTitle)
ptrTag = fhCreateItem("_FILE",ptrObje,true)
fhSetValueAsText(ptrTag, pMediaPath..pMediaName..'.'..pFormat)
ptrTag = fhCreateItem("FORM",ptrObje,true)
fhSetValueAsText(ptrTag, pFormat)
ptrTag = fhCreateItem("_KEYS",ptrObje,true)
fhSetValueAsText(ptrTag, pKeys)
end
local ptrLink = fhNewItemPtr()
ptrLink = fhCreateItem("OBJE",pSource,true)
if ptrLink:IsNotNull() then
fhSetValueAsLink(ptrLink,ptrObje)
end
end
Code: Select all
--------------------------------------------------------------------------------
-- AddMedia
-- Changed 12 Dec 2020 to reflect changes to GEDCOM structure for 5.5.1
--------------------------------------------------------------------------------
function AddMedia(pMediaPath, pMediaName, pMediaTitle, pFormat, pKeys, pSource)
local ptrObje = fhCreateItem("OBJE")
if ptrObje:IsNotNull() then
local ptrFile = fhCreateItem("FILE",ptrObje,true)
fhSetValueAsText(ptrFile, pMediaPath..pMediaName..'.'..pFormat)
local ptrTag = fhCreateItem("TITL",ptrFile,true)
fhSetValueAsText(ptrTag, pMediaTitle)
ptrTag = fhCreateItem("FORM",ptrFile,true)
fhSetValueAsText(ptrTag, pFormat)
ptrTag = fhCreateItem("_KEYS",ptrObje,true)
fhSetValueAsText(ptrTag, pKeys)
end
local ptrLink = fhNewItemPtr()
ptrLink = fhCreateItem("OBJE",pSource,true)
if ptrLink:IsNotNull() then
fhSetValueAsLink(ptrLink,ptrObje)
end
end
Regards,
Shosh