* Source RecordId

For plugin authors to discuss plugin programming
Post Reply
avatar
SimPar
Gold
Posts: 25
Joined: 07 Mar 2015 16:20
Family Historian: V7

Source RecordId

Post by SimPar »

Hi all,

I am writing a plugin to output data in HTML format. I am having trouble in one area. I need to output the RecordId for sources linked to facts and other data. An example being the source for an individual's name. In a query this works =RecordId(%INDI.NAME.SOUR>%) but I can't get it to work in Lua. I have tried a number of variations of the syntax and searched many lines of Lua code for inspiration. Perhaps there's a builtin function that I am unaware of.

Any suggestions?

Simon
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Source RecordId

Post by ColeValleyGirl »

Have you looked at the help on the FH API? e.g. https://www.family-historian.co.uk/help ... cordid.htm
avatar
SimPar
Gold
Posts: 25
Joined: 07 Mar 2015 16:20
Family Historian: V7

Re: Source RecordId

Post by SimPar »

Hi Helen,

Thanks for your suggestion.

I have previously looked at that. I've just tried that code snippet again changing the BIRT references to NAME and this is what it shows for me as the first person in the file:

Simon PARSONS
Name: Simon PARSONS
Record1:1
Record2:0

When I move forward in the file the value of Record1 increases as expected and shows the RecordId for the individual. The Record2 value of 0 is no apparent help. I need to show the recordId for the SOUR record cited against the individual's name.

I expect I'm missing something simple

Regards
Simon
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Source RecordId

Post by ColeValleyGirl »

If you post your code here (Use the </> button to format it as code), it will be easier to see what's going wrong.
avatar
SimPar
Gold
Posts: 25
Joined: 07 Mar 2015 16:20
Family Historian: V7

Re: Source RecordId

Post by SimPar »

Hi Helen

Test code as requested. It is just the snippet from the documentation

Code: Select all

ptr = fhNewItemPtr()
ptrName = fhNewItemPtr()
ptr:MoveToFirstRecord('INDI')
ptrName = fhGetItemPtr(ptr,'INDI.NAME')
iRecordId = fhGetRecordId(ptr)
iRecordId2 = fhGetRecordId(ptrName)
fhMessageBox(fhGetDisplayText(ptr)..
             '\n'..fhGetDisplayText(ptrName)..
             '\nRecord1:'..iRecordId..
             '\nRecord2:'..iRecordId2)
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Source RecordId

Post by ColeValleyGirl »

prtName points to a Name, not a record, so it doesn't have a record ID.

The API documentation does mention that.
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Source RecordId

Post by tatewise »

Sorry to jump in, but the documentation is quite clear. The pointer must refer to a record, not a field.
iRecordId is the Record Id of ptr which is the Individual Record pointer .

iRecordId2 is always 0 because its pointer refers to the Birth tag or the Name tag.
The documentation says: "Here only the ptr will return a non zero value for fhGetRecordId".
i.e. iRecordId has a non zero value but iRecordId2 is always 0

You need to use fhGetRecordId(ptrSour) where ptrSour is obtained from the data ref %INDI.NAME.SOUR>%
i.e. ptrSour = fhGetItemPtr(ptr,'INDI.NAME.SOUR>')
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
SimPar
Gold
Posts: 25
Joined: 07 Mar 2015 16:20
Family Historian: V7

Re: Source RecordId

Post by SimPar »

That's the baby! I was lacking an understanding of fhGetItemPtr()

Thanks both.

Simon
User avatar
BEJ
Famous
Posts: 210
Joined: 10 Sep 2018 17:29
Family Historian: V7
Location: Boston, Massachusetts, USA
Contact:

Re: Source RecordId

Post by BEJ »

Love to know when the plugin is available. Will you post when completed in the forum?
avatar
SimPar
Gold
Posts: 25
Joined: 07 Mar 2015 16:20
Family Historian: V7

Re: Source RecordId

Post by SimPar »

Hi Bej and maybe others,

The answer that Mike gave me certainly meant I could proceed with the project - thanks Mike. However, I next ran into restrictions posed by the FH Report plugin functionality. I was trying to replicate a version of the Summary Report that I had developed via another convoluted route. The upshot being that the FH way was going to be tricky - if even possible. I decided to go back to basics and create my report straight from a Gedcom file. Now, I could do this in Lua but frankly I have never got on with it as a language despite being a retired programmer. I have worked in Basic, Fortran, RPG, CICs, COBOL, GENEROL , VB, Easytrieve, Pascal, MVC and C# but can't seem to find any love for Lua. I think it's the dependence on pointers! I have therefore moved to finishing the project in C#

I'm a lazy coder these days and the code I'm writing will work with the data I throw at it (I can debug it on the fly) but will not be robust enough to expose to the wider world - sorry! Neither would it be customizable. It's also incredibly inefficient as I pass through the Gedcom file several times. Still only takes a short time to run but I would be embarrassed to show such lack of professionalism. With luck I should finish the project this coming week.

If you are after Genealogy stuff in HTML I suggest you take a look at the fantastic Gedsite program by John Cardinal. It builds websites from Gedcom data and handles Family Historian very well. You can build a web page version of something which looks very much like the Individual Summary Report - or even better!

Sorry for the delay in replying and the lack of anything to share.

Happy New Year to one and all.

Simon
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Source RecordId

Post by tatewise »

SimPar wrote: 31 Dec 2023 17:29 I have worked in Basic, Fortran, RPG, CICs, COBOL, GENEROL , VB, Easytrieve, Pascal, MVC and C# but can't seem to find any love for Lua. I think it's the dependence on pointers!
Regarding Lua, I don't think Lua is particularly dependent on pointers. I suspect Simon is referring to the FH API that relies heavily on pointers to the Project database to identify which data items to read/write.

If Simon's C# program is reading the GEDCOM file then I guess it is building its own internal database and accessing the data items directly.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Post Reply