I know it would need more refinement to generalise application (error testing, etc), but it needs to run only once on each database so can be relatively quick and dirty as long as it is correct!
Code: Select all
ptIndi = fhNewItemPtr() -- record pointer
ptIndi:MoveToFirstRecord('INDI') -- set pointer to first INDI record
while ptIndi:IsNotNull() do -- loop through individuals
ptCensus = fhGetItemPtr(ptIndi, '~.CENS')
while ptCensus:IsNotNull() do -- loop through their census events
strAddress = '' -- reset strings
strTitle = ''
strSourceAddress = ''
strAddress = fhGetItemText(ptCensus, '~.ADDR') -- census address
if strAddress == '' then
strTitle = fhGetItemText(ptCensus, '~.SOUR>TITL') -- get source title
strSourceAddress = string.match(strTitle, "%((.-)%)")
if strSourceAddress ~= nil then -- create new address field
ptAddress = fhCreateItem('ADDR', ptCensus)
fhSetValueAsText(ptAddress, strSourceAddress)
end
end
ptCensus:MoveNext('SAME_TAG')
end
ptIndi:MoveNext('SAME_TAG') -- move to next individual
end