Learning to write Plugins


Mike C
 

I am starting to learn how to write a Plugin.
 
I have copied the sample code under 'function createResultSet' on URL http://pluginstore.family-historian.co.uk/fhutils/files/createResultSet.html
  and pasted it into a new Plugin having just a Script Header.
On running it I get the error '...:15: attempt to call a nil value (global 'createResultSet')'
  for the line '15  local tblResults = createResultTable()'.
 
Adding the line 'fhfu = require("fhFileUtils");' before line 15 doesn't cure the error
  and then amending line 15 to '... fhfu.createResultTable()' still doesn't cure it.
 
Disappointed that pasted Sample Code doesn't run - what am I missing here ?
 


colevalleygirl@colevalleygirl.co.uk
 

You need ‘fh = require(‘fhUtils’)’ not 'fhfu = require("fhFileUtils"), and then amend line 15 to fh.createResultltTable()

 

fhUtils and fhFileUtils are different libraries.

 

 

 

From: family-historian@groups.io <family-historian@groups.io> On Behalf Of Mike C via groups.io
Sent: 06 November 2021 17:55
To: family-historian@groups.io
Subject: [family-historian] Learning to write Plugins

 

I am starting to learn how to write a Plugin.

 

I have copied the sample code under 'function createResultSet' on URL http://pluginstore.family-historian.co.uk/fhutils/files/createResultSet.html

  and pasted it into a new Plugin having just a Script Header.

On running it I get the error '...:15: attempt to call a nil value (global 'createResultSet')'

  for the line '15  local tblResults = createResultTable()'.

 

Adding the line 'fhfu = require("fhFileUtils");' before line 15 doesn't cure the error

  and then amending line 15 to '... fhfu.createResultTable()' still doesn't cure it.

 

Disappointed that pasted Sample Code doesn't run - what am I missing here ?

 


Mike Tate
 

Your original fhfu.createResultTable() would have worked if you had used fhfu = require("fhUtils") instead of "fhFileUtils", which as Helen says is a different library.

 

However, I think you are correct in complaining that the sample script does not run without two significant changes.

 

 


Mike C
 

Thanks Both,

The link on the FH help page for fhFileUtils is wrong - it takes you to the fhUtils page (and I didn't notice that !)
I saw createResultTable() and thought that's just what I need, and so ...


Mike C
 

CP says: "Thank you for the feedback they will be fixed for the next release." - hopefully that is the sample code, as well as the incorrect Help link.

I have a follow up question on the 'function createResultSet' sample code:
the line : tblResults.indi:set(pInd:Clone()) puts an icon and a name in the 'indi' column
I can 'hide' the name in the column by setting its width to 2 (but in the report you can drag the col width wider to show the name)
I would like to have just the icon in the 'indi' column, without the name, but can't work out how to do it

Help appreciated.


colevalleygirl@colevalleygirl.co.uk
 

What that line actually does is put the icon and a pointer to the relevant record; if you click on it, it will open the relevant record in the property box. There isn’t a way to just have the icon that I know of, and I’m not sure you’d want it without being able to see which record it linked to?

 

From: family-historian@groups.io <family-historian@groups.io> On Behalf Of Mike C via groups.io
Sent: 13 November 2021 11:59
To: family-historian@groups.io
Subject: Re: [family-historian] Learning to write Plugins

 

I have a follow up question on the 'function createResultSet' sample code:

the line : tblResults.indi:set(pInd:Clone()) puts an icon and a name in the 'indi' column
I can 'hide' the name in the column by setting its width to 2 (but in the report you can drag the col width wider to show the name)
I would like to have just the icon in the 'indi' column, without the name, but can't work out how to do it


_._,_._,_


Mike C
 

Thanks for your reply.
I'm building a custom index for the gedcom, which I will export as .csv.
Clone() displays itself as 'John SMITH', which isn't useful for an index.
I have Surname and Forenames columns, so I do know who each row relates to (without opening the Property Box).
Thanks.


colevalleygirl@colevalleygirl.co.uk
 

Is you requirement so specialised that it can’t be handled by a Query? A plugin feels a bit like a sledgehammer to crack a nut otherwise (except as a learning exercise).

 

From: family-historian@groups.io <family-historian@groups.io> On Behalf Of Mike C via groups.io
Sent: 14 November 2021 11:53
To: family-historian@groups.io
Subject: Re: [family-historian] Learning to write Plugins

 

Thanks for your reply.
I'm building a custom index for the gedcom, which I will export as .csv.
Clone() displays itself as 'John SMITH', which isn't useful for an index.
I have Surname and Forenames columns, so I do know who each row relates to (without opening the Property Box).
Thanks.


Mike C
 

I'm wanting to use several 'if...then...else' statements for 'Birth/Bapt' column, etc.
Also wanting separate rows for Aliases and second spouses, etc.
Impossible in a query ?
I program in Delphi, so this is another interesting programming experience (frustrating at times !).


colevalleygirl@colevalleygirl.co.uk
 

‘if...then...else...’ isn’t impossible in a Query, but could get complex with nested functions.

 

The separate rows would be a challenge in a Query though.

 

From: family-historian@groups.io <family-historian@groups.io> On Behalf Of Mike C via groups.io

I'm wanting to use several 'if...then...else' statements for 'Birth/Bapt' column, etc.
Also wanting separate rows for Aliases and second spouses, etc.
Impossible in a query ?
I program in Delphi, so this is another interesting programming experience (frustrating at times !).