Page 1 of 1

Converting homemade plugins to FH7

Posted: 12 Dec 2020 19:46
by shoshk
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

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
This is the new code for FH7

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
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

Re: Converting homemade plugins to FH7

Posted: 12 Dec 2020 20:55
by tatewise
Yes, excellent, that is all part of the change from GEDCOM 5.5 to GEDCOM 5.5.1.

Those are the things that plugin authors are having to update, and maintain v6 and v7 compatibility.
I hope that in due course all these will find there way into the Knowledge Base.

Other changes involve less used items such as Email _EMAIL => EMAIL and web _WEB => WWW and rich text, and a few other smaller differences.

Re: Converting homemade plugins to FH7

Posted: 13 Dec 2020 07:19
by ColeValleyGirl
I'm working on the relevant KB article now -- post anything else that should be included here?

Re: Converting homemade plugins to FH7

Posted: 13 Dec 2020 07:33
by shoshk
Is there a document which documents changes (if any) to Calico Pie's GEDCOM extensions?

Shosh

Re: Converting homemade plugins to FH7

Posted: 13 Dec 2020 08:20
by ColeValleyGirl
Shosh, not that I know of.