* Census Data Entry Plugin crash

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
avatar
AlexRWilson
Newbie
Posts: 4
Joined: 06 Jun 2023 06:59
Family Historian: V7

Census Data Entry Plugin crash

Post by AlexRWilson » 19 Jul 2023 10:50

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

User avatar
ColeValleyGirl
Megastar
Posts: 4850
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Census Data Entry Plugin crash

Post by ColeValleyGirl » 19 Jul 2023 11:08

Thanks -- will take a look but can't until tomorrow.

User avatar
Jane
Site Admin
Posts: 8440
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Census Data Entry Plugin crash

Post by Jane » 22 Jul 2023 11:45

Please note: ColeValleyGirl is offline for a few days. I will try and have a look next week, but I am working all week.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

avatar
AlexRWilson
Newbie
Posts: 4
Joined: 06 Jun 2023 06:59
Family Historian: V7

Re: Census Data Entry Plugin crash

Post by AlexRWilson » 26 Jul 2023 16:42

No rush, my code isn’t very elegant, but it works for what I need.

User avatar
ColeValleyGirl
Megastar
Posts: 4850
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Census Data Entry Plugin crash

Post by ColeValleyGirl » 10 Aug 2023 15:16

Version 1.8 in the plugin store fixes this problem.

Post Reply