* delete a file for rebuild

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
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

delete a file for rebuild

Post by Ron Melby »

I am using the table module.

There are times I want to load up into my program table, which I have saved before, and contains permanant information, but there are times I want to make a new file even if one exists and overwrite it. is there a module I am missing out on or do I build the filename and os.execute a delete in the program that refreshes the file and build it over again?

I have another question in that same vein, from a FAMC or FAMS I need to get to the actual FAM record so that I can get the record ID of it, (I am saving the table and pointers dont get it)
and later I need to go from recordID to pointer to link(??) to process it, all in all the process is a little fuzzy.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: delete a file for rebuild

Post by tatewise »

It would help if you explained what save and load mechanisms you are talking about.
I presume you mean table.save(...) and table.load(...) ?
In that case table.save(...) will always overwrite the previously saved file when you rebuild the data.

Anyway, you must know the full file path used by those functions.
See plugins:code_snippets:delete_file|> Delete File (code snippet) which also needs the full file path.

It might get confusing trying to discuss these two very different topics in one thread!!!
We discussed the FAMC & FAMS pointer scenario at length before.
Remember that the pointer to INDI.FAMC refers to that tag in the Indi record, not to Family record.
You must use ptrFAM = fhGetValueAsLink(ptrFAMC) to get the FAM record pointer.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: delete a file for rebuild

Post by Ron Melby »

I have the way there, but its the way back that is holding me at bay.

fptr = Record(345, 'F')

is that how I get back to a FAM record from a record ID?

now, having got back to a FAM record, (and I know whether it is a FAMC, or FAMS) based on its array....and having resolved the INDI pointer....


fhGetValueAsLink(?????)

How do I make that a FAMC or FAMS pointer and link it to the INDI???
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: delete a file for rebuild

Post by tatewise »

Yes, fptr is pointing to FAMily record with Id = 345

It depends which FAMC or FAMS you want to reference.
In the Family record there are pointers to each relative's Individual record:
FAM.HUSB holds pointer to husband that has INDI.FAMS pointer back to Family record.
FAM.WIFE holds pointer to the wife that has INDI.FAMS pointer back to Family record.
FAM.CHIL[1] holds pointer to 1st child that has INDI.FAMC pointer back to Family record.
FAM.CHIL[2] holds pointer to 2nd child that has INDI.FAMC pointer back to Family record.

So to get to husband's Individual record:
local hptr = fhGetItemPtr(fptr,'~.HUSB')
local iptr = fhGetValueAsLink(hptr)

or
local iptr = fhGetItemPtr(fptr,'~.HUSB>')
Now iptr points to the husband's Individual record.

( BTW: For same sex partnerships there may be two HUSB tags, or two WIFE tags, instead of one of each. )
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: delete a file for rebuild

Post by Ron Melby »

I have a record..
some table[rcdid, of the pointer] , anc{rcdid of ancestors}, dsc{rcdid of descendants} fams(rcdid of spouses) famc(rcdid of fam as child) and when I was using pointers which are not savable, I was saving the entire famc and fams entries as arrays of pointers, not concerning myself with husb, wife, chil.. I had hoped to make a network graph of it (somewhat more than that actually) but at the least to have a sort of 'hit' chart somewhat like:

name anc dsc spou chil

Melby 121 14 3 1
where I count the number of times a person shows as an ancestor, descendant, spouse, and child in the file.
I was also considering in this scenario how I might make use of sometable[rcdid as 0 ] ie sometable[0] since a rcdid never has a value 0 and putting last update in there, then figuring out the last time the gedcom was changed, compare in days and determine if it is out of date and should be run again before using it for any plugin.

but rather than save whole famc and fams I can save the rcdid of the fam and process those with functions rather than straight counting of array indexes.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: delete a file for rebuild

Post by tatewise »

I really have no idea what you are trying to do, or what problem your are trying to solve and need help with.

Instead of saving pointers you can retain effectively the same relationship by saving Record Id.
So instead of saving a pointer to a Family record, save the Family Record Id.
Similarly for a pointer to an Individual record, save the Individual Record Id.
Then you can retrieve the pointer by using fptr = Record(RecId, 'F') or iptr = Record(RecId, 'I')
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: delete a file for rebuild

Post by Ron Melby »

give me a list of most common ancestors most common descendants in my file.

one problem I am going to solve.

[1039] => (table .2)
iddsc => (table #2)
[1] => 1049
[2] => 1049
idanc => (table #116)
[1] => 1037
[2] => 1050
[3] => 2571
[4] => 2572
[5] => 2001
[6] => 1829
[7] => 1860
[8] => 1900
[9] => 1901
[10] => 1796
[11] => 2496
[12] => 2497
[13] => 412
[14] => 4612
[15] => 4613
[16] => 453
[17] => 3705
[18] => 4099
[19] => 4087
[20] => 4082
[21] => 4149
[22] => 4474
[23] => 4159
[24] => 4163
[25] => 4464
[26] => 4164
[27] => 4160
[28] => 4475
[29] => 4150
[30] => 4153
[31] => 5421
[32] => 5422
[33] => 4154
[34] => 4085
[35] => 4140
[36] => 4153
[37] => 5421
[38] => 5422
[39] => 4154
[40] => 4141
[41] => 4474
[42] => 4159
[43] => 4163
[44] => 4464
[45] => 4164
[46] => 4160
[47] => 4475
[48] => 4089
[49] => 4103
[50] => 3706
[51] => 3721
[52] => 3722
[53] => 2046
[54] => 2501
[55] => 2502
[56] => 569
[57] => 317
[58] => 2317
[59] => 1037
[60] => 1050
[61] => 2571
[62] => 2572
[63] => 2001
[64] => 1829
[65] => 1860 ....

this is a guy by the name of klemetsrud, he has a daughter rcdid 1049 (as you can see i have ran this twice, and his daughter appears twice, because I loaded the table from disk, and in THIS program, I want to delete the file if it exists (thats why I asked you an earlier question about it) and build from scratch. in OTHER analyzation programs I want to know the age of this file when I load it from the disk, and how old it is compared to the last change of my gedcom (yanno like fh does when you change the file) he also has a number of ancestors. now for every person in my file, in OTHER programs, I will load the table from disk count how many times they are an ancestor, a spouse, a descendant a child, to everyone else in my file.... i will have to add idfamc and idfams arrays to the table, as stated prior.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: delete a file for rebuild

Post by tatewise »

In the plugins:getting_started|> Getting Started Writing Plugins under Other Lua Library Modules there is the Lua File System Library described at http://keplerproject.github.io/luafiles ... anual.html.
That allows the Attributes of files to be read, including time of last modification, which is effectively creation date/time.
e.g.
require( "lfs" )
local Created = lfs.attributes (filepath,'modification')
-- where filepath is the full file path of the data file.

You may need to use Lua section 5.8 – Operating System Facilities such as os.date &/or os.time to convert to desired format, in order to compare two values.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: delete a file for rebuild

Post by Ron Melby »

thanks, I will investigate that, I am sure there are other useful functions as well.
FH V.6.2.7 Win 10 64 bit
Post Reply