* the trouble with tables

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: 878
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

the trouble with tables

Post by Ron Melby » 26 Dec 2022 04:50

the attached .fh_lua is cut to bare minimums
still rather a formidable glob of code, however it all works right enugh except the function code here:

what the program is doing:
my fathers side of the family comes from Norway. I choose myself as root and choose the sources that should contain a PAGE with a link to digitalarkivet.
I run down only my fathers side and under every individual I want to pring out the list of source types available
(in a consistent order and filled in if they are souced.
I am gleaning sources from digitalarkivet.no
I intend to print out something like the following:


> [2.1040] Family of: Knudsen, Knud and Christensdatter, Kari Marriage: 26 Jul 1857
[2615] * Knudsen, Knud ................................ M (1828 - 1924) ð (02x) great grandfather
Born
Baptised
Confirmation
1801 Census
1815 Census
1825 Census
1835 Census
1845 Census
1855 Census
1865 Census www.digitalarkivet.no/en/census/person/pf01038076002860
1870 Census
1875 Census
1885 Census
1891 Census
1900 Census
1910 Census
1920 Census
1925 Census
Emigrated
Immigrated
Died
Buried
[2616] * Christensdatter, Kari ........................ F (1832 - ) (02x) great grandmother
Born
Baptised
Confirmation
1801 Census
1815 Census
1825 Census
1835 Census
1845 Census
1855 Census
1865 Census
1870 Census
1875 Census www.digitalarkivet.no/en/census/person/pf01052105000778
1885 Census
1891 Census
1900 Census
1910 Census
1920 Census
1925 Census
Emigrated
Immigrated
Died
Buried ... and so on for each individual
[2598] * Knudsen (Melby), Knud ........................ M (1857 - 1919) great grandfather
[5229] * Knudsen, Christen ............................ M (1862 - ) great granduncle
[2619] * Knudsen (Bakken), Østen ...................... M (1864 - ) great granduncle
[5230] * Knudsdatter, Ragnhild ........................ F (1867 - ) great grandaunt
[5231] * Knudsdatter, Kari ............................ F (1870 - ) great grandaunt
[5232] * Knudsen, Ole ................................. M (1872 - 1917) ð great granduncle
[5233] * Knudsdatter, Marit ........................... F (1874 - ) great grandaunt


the problem I am having is I am not updating the table. I get no complaints, but no update line 953.
916 local function rtv_source_records(ptr, _rcdtype, _ptrSRC, _itbl)
ptr = ptrINDI
_rcdtype = 'INDI'
_ptrSRC = table of my 9 nowwegian sources
_itbl is a default indexed table of human version of Event Labels gotten from i_dft pattern table defined at 880
<snip>
925 local function mat_source_records(_itbl)
<snip>
951 for i, var in ipairs(_itbl) do
for k, val in pairs(var) do
if k == EVT then
953** k = WEB
break -- return _itbl
end
end -- for
end -- for _itbl
return _itbl
end -- fn mat_src_records
<snip>

this line starts the process
999 iFACT[iptr] = rtv_source_records(iptr, 'INDI', _ptrSRC, i_dft)

what I would expect to see for instance is:

[1] {Born = '')
changed to
[1] {Born = 'www.digitalarkivet.no/en/view/327/pv00000004828346'}

what am I doing wrong here?
.allNOR.fh_lua
(30.14 KiB) Downloaded 18 times
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: the trouble with tables

Post by tatewise » 26 Dec 2022 16:22

What are you expecting k = WEB to do?

It cannot update a table because k holds the name of an entry key for table var, i.e. var[k] holds the value val.

If you want to change the value of the entry associated with that key then you must use:
var[k] = WEB i.e. replace the value in val with the value in WEB
which is the same as:
_itbl[k] = WEB
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply