* Penlight Library

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Penlight Library

Post by Ron Melby » 18 Mar 2020 23:41

Helen, you shamed me into it.

I have the penlight library in the LUA_PATH

require('tabelx')

massive failure, not found,

what fresh hell is this?

Ron Parker author.
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 19 Mar 2020 07:11

You need to 'loadrequire' it first: see Knowledge Base > Module Require With Load (code snippet). The first time it's run this will download the library to your PC, thereafter it's the same as require.

Code: Select all

    if not LoadRequire("pl","pl.init") then return end -- Load required Penlight modules
    pl = require("pl.import_into") --makes the individual modules without having to require them individually 

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 11:35

the penlight library is in my plugins.

I find no luaconf.h on my computer
and looking at the package.path from within fh.... its non-compliant.
fhloadrequire nor LoadRequire is not in the lua help index.
I am trying to steal whatever is necessary to nick this screen from Research Planner and run it in a do nothing script to build on it, it is the closest example to what I will need.
opt.png
opt.png (11.71 KiB) Viewed 768 times
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 19 Mar 2020 11:49

the Loadrequire code is at the knowledgebase page I pointed you to; you need to drop it into your plugin.

When you say you're trying to nick the code (and go ahead, use whatever you want frommy plugins), do you want a popup windows for options (I suspect not) or a basic iup dialaog? If you can give me some (simple) idea about what you actually want, I can steer you towards what to steal -- but the Miltifact plugin might be a simpler place to start.

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 12:53

ok, figured out fhloadrequire it is your name not an fh function
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 13:15

what I am looking to do, is make a global uhhhhh... variable table.
so I have 4 or 5 and looking to increase it to 9 or 10 tables for example that I load and some save.
I have other things I use for this and that.

so, given the screen I posted, ... rather than radio buttons they would be dropdowns. there would be at least one input box beside it.
so lets say...
dropdown might be
*savrst inputbox might be places and it would require another box beside that, filepath
*sysvar inputbox variable name input box value
*datfmt inputbox dd/mm/yy doesnt need a third.

and so on and so forth and not totally thought out.

so minumum a type, value, extravalue might occur
as I select the dropdown, I wonder if there is some callback function that would allow me to update the screen with another input box or some other update to the screen.

I have very simple selection screens and message boxes at present, but looking to do advanced stuff while waiting on events (5.3) or better.... or even a more powerful language. and everyone has their way of coding, and I would like to start organizing screen code....
some standardized layout internal to the screen code. so that like my other code, I fundamentally get a framework and just fill in parts.
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 19 Mar 2020 14:15

Have a look at the Dialog helper functions in my plugins, to start with.

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 16:42

I found no actual 'dialog helper' but looking at your research planner they seem to be from MakeDialog to MakeDateField and everything in between in the zb outline. is that correct?
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 19 Mar 2020 17:29

Starts with something like:

Code: Select all

--[[ Dialog
@Author:      Helen Wright
@Version:      1.0
@LastUpdated:  29 October 2019
@Description:  Helper functions for IUP dialogs
@V1.0:        Initial version.
]]--
and ends with the MakeDateField function.

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 18:07

good, I understood it on a surfactant level then.

one of the questions I have is that you have several functions wrapped in do
does that mean that the functions run at startup without any call to them, or what is the purpose of that?
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 19 Mar 2020 19:50

I use the do-end construct to localise variables (restrict the scope to the code block) and also to make it easy to fold/unfold great chunks of code as once in Zb. The functions don't run unless they're called

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 20:03

I was unaware you could access something directly inside a do from outside. learned something new. Good news is I got it to compile without errors and run, doing nothing.

now to boost the options screen and see what I got shakes out.
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 19 Mar 2020 22:30

well all day, cant find where it starts executing the screens. just a few minutes later I found it. But I have to say this is like cutting tarpstraps all day.
FH V.6.2.7 Win 10 64 bit

User avatar
ColeValleyGirl
Megastar
Posts: 1574
Joined: 28 Dec 2005 22:02
Family Historian: V6.2
Location: Cirencester, Gloucestershire
Contact:

Re: Penlight Library

Post by ColeValleyGirl » 20 Mar 2020 06:58

Everybody's code style is different -- I can't make head nor tail of your code, nor of Mike Tate's, most of the time. I think it depends on how each person's brain is wired.

User avatar
Ron Melby
Megastar
Posts: 522
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Penlight Library

Post by Ron Melby » 20 Mar 2020 14:04

LOL. agreed. When I was a working code guy, I thought IBMs example usage code or tips and tricks code snippets were childish and inept. And my bosses code for our company was spaghetti and randomly placed, nobody understood his code or his concept, but we sold a ton of it.
FH V.6.2.7 Win 10 64 bit

Post Reply