Page 1 of 1

Census Data Entry Plugin crash

Posted: 19 Jul 2023 10:50
by AlexRWilson
I have been getting a crash in the Census Data Entry plugin. This occurs when I am entering data for 1841 Census with an age of "9m". 9M is accepted as entry but the error occurs on line 645 when iAgeInYears is chaecked - as the age is months only this variable is still set to false and you get the crash:

[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:645: attempt to compare number with boolean
stack traceback:
[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:645: in function 'addData'
[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:547: in function 'doDetail'
[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:194: in function <[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:193>
(...tail calls...)
[C]: in function 'iuplua.MainLoop'
[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:165: in function 'main'
[string "C:\ProgramData\Calico Pie\Family Historian\Pl..."]:2414: in main chunk

I altered the function to check for this in my version to also check the months:
- added variable iAgeInMonths
- Set iAgeInMonths from callback from calcBirth
- Added logic statement to set iAgeInYears to 0 if iAgeInMonths is set

I also notice this could probably happen if an age is entered in Days only, but did not check for that.

In "function addData(ptrRecord, result, t)" added:

-- Create Birth?
if v.dr == "BIRT" then
local dtBirth = fhNewDate()
local strError
local iAgeInYears
local iAgeInMonths

if fBirthDate then
dtBirth = fBirthDate
elseif fAge then
dtBirth, strError, iAgeInYears, iAgeInMonths =
calcBirth(dDate, utils.choose(fAge == "Under one month", "1m 0d", fAge))

local dp1 = dtBirth:GetDatePt1()
--
-- IF Ages is entered as months only this will fail dues to iAgeInYears being false, added check
--
if iAgeInYears == false and iAgeInMonths then iAgeInYears=0 end

if iYear == 1841 and iAgeInYears > 15 and iAgeInYears % 5 == 0 then
-- 1841 Census ages were supposed to be rounded down to the nearest 5 years for people over 15
local sAge = tostring(iAgeInYears - 4)
local dtMax = calcBirth(dDate, sAge)
local dp2 = dtMax:GetDatePt1()
dtBirth:SetRange("between", dp1, dp2)
end

Re: Census Data Entry Plugin crash

Posted: 19 Jul 2023 11:08
by ColeValleyGirl
Thanks -- will take a look but can't until tomorrow.

Re: Census Data Entry Plugin crash

Posted: 22 Jul 2023 11:45
by Jane
Please note: ColeValleyGirl is offline for a few days. I will try and have a look next week, but I am working all week.

Re: Census Data Entry Plugin crash

Posted: 26 Jul 2023 16:42
by AlexRWilson
No rush, my code isn’t very elegant, but it works for what I need.

Re: Census Data Entry Plugin crash

Posted: 10 Aug 2023 15:16
by ColeValleyGirl
Version 1.8 in the plugin store fixes this problem.