* Howto fh.getParam with childupdate
Howto fh.getParam with childupdate
I am trying to use fh.getParam to update list 2 depending on a selection in list 1. From the help on getParam I understand that this should be possible by using the childUpdate and child options.
But I must be doing something wrong because my childUpdate function doesn't get called.
A working example of list 1 steering the content of list 2 would be a great help.
But I must be doing something wrong because my childUpdate function doesn't get called.
A working example of list 1 steering the content of list 2 would be a great help.
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: Howto fh.getParam with childupdate
This is a place and address example, but should illustrate the general principles:
Code: Select all
{tag='BAPTISMPLACE', type="STRING" ,label= 'Baptism place', value='', child='BAPTISMADDRESS', childUpdate=function(place) return fh.createAddressList(place) end},
{tag='BAPTISMADDRESS', type="STRING", label= 'Baptism address', value=''}Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history
Re: Howto fh.getParam with childupdate
Thanks Helen,
I understand the example but can't seem to get it working with two lists. Question, where does the argument place come from?
Maybe it's not meant to be possible, but the idea is to have a list 1 (type = 'LIST') and based on a selection of the user in list 1 change te contents of list 2 (type = 'LIST'). The function I use is not in line (isn't necessary, is it?) because it's rather long.
I understand the example but can't seem to get it working with two lists. Question, where does the argument place come from?
Maybe it's not meant to be possible, but the idea is to have a list 1 (type = 'LIST') and based on a selection of the user in list 1 change te contents of list 2 (type = 'LIST'). The function I use is not in line (isn't necessary, is it?) because it's rather long.
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: Howto fh.getParam with childupdate
In the example 'place' is the value of the BAPTISMPLACE field -- I could have called it x but it would still be the value of the 'parent' field.
I don't have an example of one list updating the contents of another, but it should work -- you'd need to return a table of values that will also be the child field prompts (i.e. you can't have different prompts and values).
I don't have an example of one list updating the contents of another, but it should work -- you'd need to return a table of values that will also be the child field prompts (i.e. you can't have different prompts and values).
Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history
Re: Howto fh.getParam with childupdate
I don't see it.
Got a lua error and it hangs:
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:181: attempt to call a table value (field 'childUpdate')
stack traceback:
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:181: in upvalue 'updateChild'
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:507: in function <... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:497>
(...tail calls...)
[C]: in function 'iuplua.Popup'
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:743: in function 'fhUtils.getParam'
[string "C:\Users\Joop\AppData\Local\Temp\~fhC889.tmp"]:76: in function 'main'
[string "C:\Users\Joop\AppData\Local\Temp\~fhC889.tmp"]:264: in main chunk
My statement is:
local fpar = fh.getParam('Field mapping', nil,
{{tag = 'tNotMappedText', label = 'Field to map to', type = 'LIST', value = tNotMappedText[1], values = tNotMappedText, childUpdate = doNewMatch(tCanMatch, value), child = 'tCanMatchText'},
{tag = 'tCanMatchText', label = 'Field to map to', type = 'LIST', value = tCanMatchText[1], values = tCanMatchText}},
{'OK, next', 'Auto-match', 'Reset', 'Cancel'})
What am I doing wrong?
Got a lua error and it hangs:
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:181: attempt to call a table value (field 'childUpdate')
stack traceback:
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:181: in upvalue 'updateChild'
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:507: in function <... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:497>
(...tail calls...)
[C]: in function 'iuplua.Popup'
... Files (x86)\Family Historian\Program\Lua\fhUtils.fh_lua:743: in function 'fhUtils.getParam'
[string "C:\Users\Joop\AppData\Local\Temp\~fhC889.tmp"]:76: in function 'main'
[string "C:\Users\Joop\AppData\Local\Temp\~fhC889.tmp"]:264: in main chunk
My statement is:
local fpar = fh.getParam('Field mapping', nil,
{{tag = 'tNotMappedText', label = 'Field to map to', type = 'LIST', value = tNotMappedText[1], values = tNotMappedText, childUpdate = doNewMatch(tCanMatch, value), child = 'tCanMatchText'},
{tag = 'tCanMatchText', label = 'Field to map to', type = 'LIST', value = tCanMatchText[1], values = tCanMatchText}},
{'OK, next', 'Auto-match', 'Reset', 'Cancel'})
What am I doing wrong?
Re: Howto fh.getParam with childupdate
Forgot to include the update function.
function doNewMatch(tCanMatch, value)
--
-- Updates matching fields for new value in old fields list in getParam
if value then
tCanMatch = getMatch(tNewFields, value)
end
local tCanMatchText = getDisplayText(tCanMatch)
return tCanMatchText
end
function doNewMatch(tCanMatch, value)
--
-- Updates matching fields for new value in old fields list in getParam
if value then
tCanMatch = getMatch(tNewFields, value)
end
local tCanMatchText = getDisplayText(tCanMatch)
return tCanMatchText
end
Re: Howto fh.getParam with childupdate
I think I have removed some inconsistencies, but still can't get it to work; it still ends with a lua error when I select a different item in list 1 (tNotMappedText). Every hint on this - for me new - use of Lua and fh.getParam is highly apricated.
The getParam statement is now:
local fpar = fh.getParam('Field mapping', nil, {{tag = 'tNotMappedText', label = 'Field to map', type = 'LIST',
value = tNotMappedText[1], values = tNotMappedText, childUpdate = doNewMatch(sOldField), child = 'tCanMatchText'},
{tag = 'tCanMatchText', label = 'Field to map to', type = 'LIST', value = tCanMatchText[1], values = tCanMatchText}},
{'OK, next', 'Auto-match', 'Reset', 'Cancel'})
The function doNewMatch is a local function as follows:
function doNewMatch(sOldField)
--
-- Updates matching fields for new value in old fields list in getParam
if sOldField then
tCanMatch = getMatchText(tCanMatch, tCanMatchText, sOldField)
end
return getDisplayText(tCanMatch)
end
The getParam statement is now:
local fpar = fh.getParam('Field mapping', nil, {{tag = 'tNotMappedText', label = 'Field to map', type = 'LIST',
value = tNotMappedText[1], values = tNotMappedText, childUpdate = doNewMatch(sOldField), child = 'tCanMatchText'},
{tag = 'tCanMatchText', label = 'Field to map to', type = 'LIST', value = tCanMatchText[1], values = tCanMatchText}},
{'OK, next', 'Auto-match', 'Reset', 'Cancel'})
The function doNewMatch is a local function as follows:
function doNewMatch(sOldField)
--
-- Updates matching fields for new value in old fields list in getParam
if sOldField then
tCanMatch = getMatchText(tCanMatch, tCanMatchText, sOldField)
end
return getDisplayText(tCanMatch)
end
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: Howto fh.getParam with childupdate
Joop, the childupdate function for the first list must return a table of values to populate the new list. (Looking at the code of fhUtils it looks like it will work with a table of values and a table of prompts.
Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history
Re: Howto fh.getParam with childupdate
Helen, I'm completely lost. I made a very simple test script that is expected to do nothing more than depending on a name in the top list, change the entries in the bottom list. As soon as I change the top list I get the lua error and when I exit this, FH quits.
Either I don't understand the parameters of fh.getParam at all or what I'm trying is not meant to be possible with this utility. I've attached the test script in the hope that you (or anybody else reading this) can help me see the light in the (for me) dark fh.getParam forest. Thanks!!
N.B. Be aware that running this script and changing the top lists quits FH. So save what needs be saved before running.
Either I don't understand the parameters of fh.getParam at all or what I'm trying is not meant to be possible with this utility. I've attached the test script in the hope that you (or anybody else reading this) can help me see the light in the (for me) dark fh.getParam forest. Thanks!!
N.B. Be aware that running this script and changing the top lists quits FH. So save what needs be saved before running.
- Attachments
-
Test getParam.fh_lua- (934 Bytes) Downloaded 94 times
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: Howto fh.getParam with childupdate
1. Try replacing the relevant lines with:
The changes are 'childUpdate = change, child = 'countries'
2. when you get a Lua error message press Continue not Exit to keep FH open (you may need to Continue through a number of errors).
Code: Select all
local fpar = fh.getParam('Allocate person to country', nil,
{{tag = 'persons', label = 'person', type = 'LIST', value = persons[1], values = persons, childUpdate = change, child = 'countries'},
{tag = 'countries', label = 'country', type = 'LIST', value = countries[1], values = countries}},
{'OK', 'Cancel'})
2. when you get a Lua error message press Continue not Exit to keep FH open (you may need to Continue through a number of errors).
Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history
Re: Howto fh.getParam with childupdate
It works!
Thanks very much Helen!
Thanks very much Helen!