* table tunnelling.

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

table tunnelling.

Post by Ron Melby » 23 Oct 2020 13:55

I have a table of tables that looks like this:

Code: Select all

ANCRCD => (table .1)
	[37] => (table .9)
		mdat => "21 October 1951"
		FAM => "MELBY, Morris Carl and MELBY, (HOOK) Ruth Jeanette"
		fID => 37
		MDAT => "21 Oct 1951"
		ix => 1
		fptr (item) => Family: ...of Morris Carl MELBY and Ruth Jeanette HOOK
	
		CHIL => (table #5)
			[1] => (table .8)
				BIRTH => "1952"
				NAME => "LEINEN, (MELBY) Morralee Ruth"
				iID => 73
				SEX => "F"
				iPTR (item) => Individual: Morralee Ruth MELBY
				RLT => "sister"
				ERA => "(1952 -     )"
				DEATH => "    "
			[2] => (table .8)
				BIRTH => "1952"
				NAME => "MELBY, Ronnalee Jeanette"
				iID => 74
				SEX => "F"
				iPTR (item) => Individual: Ronnalee Jeanette MELBY
				RLT => "sister"
				ERA => "(1952 - 1952)"
				DEATH => "1952"
			[3] => (table .8)
				BIRTH => "1954"
				NAME => "MELBY, Ronald Nolan"
				iID => 78
				SEX => "M"
				iPTR (item) => Individual: Ronald Nolan MELBY
				RLT => "root"
				ERA => "(1954 -     )"
				DEATH => "    "
			[4] => (table .8)
				BIRTH => "1954"
				NAME => "MELBY, Donald Neil"
				iID => 71
				SEX => "M"
				iPTR (item) => Individual: Donald Neil MELBY
				RLT => "brother"
				ERA => "(1954 -     )"
				DEATH => "    "
			[5] => (table .8)
				BIRTH => "1960"
				NAME => "MELBY, Richard Charles"
				iID => 77
				SEX => "M"
				iPTR (item) => Individual: Richard Charles MELBY
				RLT => "brother"
				ERA => "(1960 -     )"
				DEATH => "    "
		
		WIFE => (table .9)
			BIRTH => "1922"
			ORD => 3
			iID => 53
			SEX => "F"
			iPTR (item) => Individual: Ruth Jeanette HOOK
			RLT => "mother"
			NAME => "MELBY, (HOOK) Ruth Jeanette"
			ERA => "(1922 - 2007)"
			DEATH => "2007"

		HUSB => (table .9)
			BIRTH => "1918"
			ORD => 2
			iID => 75
			SEX => "M"
			iPTR (item) => Individual: Morris Carl MELBY
			RLT => "father"
			NAME => "MELBY, Morris Carl"
			ERA => "(1918 - 2006)"
			DEATH => "2006"
I have moved some things around without actually altering the table as built. I have a header, and three arrays, HUSB, WIFE, CHIL (an array of arrays

I want to address (retrieve the pointer - whatever you want to call it) the entry:
iPTR (item) => Individual: Morris Carl MELBY

I have tried among others which seem the most logically correct:
ANCRCD[fiD].HUSB.iPTR
ANCRCD[fiD][HUSB].iPTR

And of course they are not. I have searched for examples and read the documentation, but have not found an answer,
this is about as complex a table as I have ever worked with. I am at a dead end. Help. Thank you.

If I cant get at the first level array, I have no hope of addressing the CHIL array entries.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 19156
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: table tunnelling.

Post by tatewise » 23 Oct 2020 14:35

As long as variable fiD holds the number 37 then this should work:
local ptr = ANCRCD[fiD].HUSB.iPTR

The equivalent using square brackets would be:
local ptr = ANCRCD[fiD]["HUSB"]["iPTR"]

When debugging in the Plugin editor insert some temporary statements such as:
local recd = ANCRCD
local data = ANCRCD[fiD]
local husb = ANCRCD[fiD].HUSB
local ptr = ANCRCD[fiD].HUSB.iPTR

Set a breakpoint on first statement and step through one line at a time viewing contents of recd, data, husb, ptr in turn.
Do they hold what you expect?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

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

Re: table tunnelling.

Post by Ron Melby » 23 Oct 2020 17:31

using magiscule and miniscule correctly is good spelling and it is imprortranth. thanks. immediately apparent when I did that.
FH V.6.2.7 Win 10 64 bit

Post Reply