Page 1 of 1
Plugin Tutorial
Posted: 14 Apr 2016 14:31
by quarlton
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.
Re: Plugin Tutorial
Posted: 14 Apr 2016 19:20
by tatewise
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.
Re: Plugin Tutorial
Posted: 14 Apr 2016 21:55
by quarlton
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.
Re: Plugin Tutorial
Posted: 14 Apr 2016 21:59
by tatewise
Is there anything in particular that you are struggling with?
What wheel did you spend all day re-inventing?
Re: Plugin Tutorial
Posted: 14 Apr 2016 22:31
by quarlton
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.
Re: Plugin Tutorial
Posted: 14 Apr 2016 23:54
by tatewise
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
Re: Plugin Tutorial
Posted: 15 Apr 2016 07:44
by quarlton
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.
Re: Plugin Tutorial
Posted: 15 Apr 2016 09:43
by tatewise
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".
Re: Plugin Tutorial
Posted: 15 Apr 2016 11:34
by quarlton
Thanks for that Mike.