* Plugin Tutorial

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
avatar
quarlton
Famous
Posts: 150
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Plugin Tutorial

Post by quarlton » 14 Apr 2016 14:31

Does anyone know if there are any Plugin tutorials on offer anywhere?
I've spent a good part of my day re-inventing the wheel and would welcome a tutorial to attend.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

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

Re: Plugin Tutorial

Post by tatewise » 14 Apr 2016 19:20

Dave, did you not go the Plugin Course anyone (6067) run by Jane?

There is a great deal of tutorial information provided, in the FH Help and our Knowledge Base and more generally for LUA.
Have you investigated:
  • Tools > Plugins > More>> > How to Write Plugins Help pages that have introductions and samples.
  • plugins:index|> Family Historian Plugins especially the Developer Guide plugins:getting_started|> Getting Started Writing Plugins and plugins:code_snippets:index|> Code Snippets.
  • Programming in Lua (first edition) is free online.
  • The Plugin Store has plenty of scripts to plagiarise, and there are also many ATTACHMENTS to Forum postings.
  • You are welcome to ask for advice here to point you in the right direction. That is a primary purpose of this Forum.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Famous
Posts: 150
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Plugin Tutorial

Post by quarlton » 14 Apr 2016 21:55

Mike, thanks for the reply.

No, I didn't get chance to go to Jane's tutorial as we were away on holiday.
It was something like that that I was hoping for.

I've looked at a good deal of the information that you list - with varying degrees of success.
I'm afraid my background in SQL and VB etc doesn't really seem to map across to Lua particularly well :(

Thanks for the pointers though.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

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

Re: Plugin Tutorial

Post by tatewise » 14 Apr 2016 21:59

Is there anything in particular that you are struggling with?

What wheel did you spend all day re-inventing?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Famous
Posts: 150
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Plugin Tutorial

Post by quarlton » 14 Apr 2016 22:31

How long have you got? :-)

I suppose the biggest problem I'm facing is finding the methods that I need to use to achieve relatively simple tasks.
The functions are there, but sometimes finding them isn't quite as straightforward as I'd hoped.

Case in point, a friend asked me if it was possible to have a query to show Indi records updated in the last 30 days.
Simple I thought.
If Today() - LastUpdated < 30 then add to list

I had expected to be able to get Today() straight from within Lua, and yes you can use os.date but that returns a string which you then need to cast to get it into a date.

I eventually realised that I can use the standard FH functions by using fhCallBuiltInFunction("functionname").

I eventually got a working plugin that gives - thanks to the interface buttons snippet posted by you and Jane - the option of 7, 14 or 30 days.
All working excellently on v6.
Sent it off to my friend and found that it doesn't appear to work in v5.
So now have to get a copy of v5 installed on one of my machines to find out what is failing. Tried it on one machine and found that the plugin editor starts running on its own!

No doubt I'll get there in the end - frustrating more than anything.

Thanks for the patient ear.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

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

Re: Plugin Tutorial

Post by tatewise » 14 Apr 2016 23:54

The probable reason it does not work in FH V5 is that it is saved in the default UTF-8 format.
You need to use the File > Encoding > ANSI command in the Plugin editor.

Maybe it was a worthwhile exercise for a Plugin but it is easily implemented as a Query.

Start with the standard Last Updated Individual Records query, and Query Menu > Save As Custom Query.
Then add a Rows filter:
Condition: Add if
Expression: =Number( DayNumber( Today() ) - DayNumber( LastUpdated() ) )
Operator: is less than
Tick the Parameter and choose a Label
Finally click Add
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Famous
Posts: 150
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Plugin Tutorial

Post by quarlton » 15 Apr 2016 07:44

Many thanks for that Mike
I've changed it to ANSI and it worked fine on v5.

Yes, implementing it as a Plugin was the main aim of the exercise and, despite the frustration, was a success in the end.

Now I need to find something else to create a Plugin for to build up my knowledge.

The coding for the query is also very helpful.

Again, thanks for your help.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

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

Re: Plugin Tutorial

Post by tatewise » 15 Apr 2016 09:43

The snag with ANSI encoding is the Plugin will convert any UNICODE accented letters to unaccented, and other symbols become question marks.

Some say that rather than adapting Plugins for FH V5 users, they should be encouraged to upgrade to FH V6 so the fees help ensure the survival of Calico Pie.

However, to make Plugins both FH V5 and FH V6 compatible I use ANSI encoding and insert the following code:

Code: Select all

if fhGetAppVersion() > 5 then		-- Cater for Unicode UTF-8 from FH Version 6 onwards
	fhSetStringEncoding("UTF-8")
	iup.SetGlobal("UTF8MODE","YES")
	iup.SetGlobal("UTF8MODE_FILE","NO")
end
The two IUP statements are only needed if you use "iuplua".
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Famous
Posts: 150
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Plugin Tutorial

Post by quarlton » 15 Apr 2016 11:34

Thanks for that Mike.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

Post Reply