* Save project gedcom from plugin

For plugin authors to discuss plugin programming
Post Reply
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Save project gedcom from plugin

Post by shoshk »

Is there a way to force an immediate save of the project gedcom from a plugin?

Why do I need this?

I am working on a data assistant (actually, it's been around for a while).

Most of the time it works, however, occasionally, it causes FH to crash. Annoying, but not a showstopper, because we can usually get things working again by restarting the computer. So, I guess, very annoying. And I finally decided to fix it.

Anyway, the problem does not happen when using the debugger, so I am resorting to the time-honored technique of sprinkling my code with "I'm here" messages, so I can figure out exactly where the problem is. I'm currently writing my messages to the change notes for the source record, which I use to keep track of where I am in the process. My problem is that I lose the information when FH crashes.

So, I would like to force a save of the project gedcom whenever I update the change notes.

Is there a way to do it?

Thanks,
Shoshana
Shosh Kalson
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Save project gedcom from plugin

Post by shoshk »

I figured out an alternative solution. I'm writing trace messages to a text file on my computer. Nothing fancy; using io.output(), io.write() and io.flush(). I believe that solves the problem.

Of course, I haven't had one crash since adding a few trace statements. LOL
Shosh Kalson
User avatar
Mark1834
Megastar
Posts: 2511
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Save project gedcom from plugin

Post by Mark1834 »

It's called the "Observer Effect" - the act of observation (adding debug lines) changes the state of the observed system (the script without debug lines)... :)
Mark Draper
User avatar
ColeValleyGirl
Megastar
Posts: 5504
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Save project gedcom from plugin

Post by ColeValleyGirl »

I don't see why fhSaveTextFile shouldn't work, or createTextFile from fhFileUtils, but I haven't tried either, and FH might hiccup when the plugin ends...?
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Save project gedcom from plugin

Post by shoshk »

Hi Mark,

Yeah, I know. But, you know, I only added a few lines, and if that solves the problem, I’m happy and so is my husband (my user). I’ve suspected for some time that there’s some kind of timing issue; haven’t been able to run it down.

Regards,
Shosh
Shosh Kalson
avatar
shoshk
Superstar
Posts: 280
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Save project gedcom from plugin

Post by shoshk »

Helen,

I considered doing that, but was concerned that there might be a conflict with the internal FH save process.

Generating a trace file is easy and probably safest. I am not aiming to ever distribute my plugin, so solutions like this are OK, I think.

Shosh
Shosh Kalson
Post Reply