* Census indexing by year

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
DavidNewton
Superstar
Posts: 464
Joined: 25 Mar 2014 11:46
Family Historian: V7

Census indexing by year

Post by DavidNewton »

I suspect this is a question that has been answered but I couldn't find an answer. I was looking for the existence of a census event of a particular year but the year is the value of a variable and that apparently does not work. An example:
pi=fhNewItemPtr()
picen=fhNewItemPtr()
pi:MoveToRecordById('INDI',8)
x=1891
picen:MoveTo(pi,'~.CENS[year=1891]')
print(fhGetDisplayText(picen))
picen:MoveTo(pi,'~.CENS[year=x]')
print(fhGetDisplayText(picen))
The first method putting the year as a constant returns the census summary, but the second method with a variable yields a null picen
Is this by design?

David
(still using v6.2)
User avatar
Jane
Site Admin
Posts: 8518
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Census indexing by year

Post by Jane »

Well you told it to use year x so I am not surprised.

Code: Select all

picen:MoveTo(pi,'~.CENS[year=x]')
You need to build the string it will not magically spot you mean x is a variable.
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
jelv
Megastar
Posts: 611
Joined: 03 Feb 2020 22:57
Family Historian: V7
Location: Mere, Wiltshire

Re: Census indexing by year

Post by jelv »

In case you don't get what Jane is saying (and for anyone else reading this topic):

Code: Select all

picen:MoveTo(pi,'~.CENS[year=' .. x .. ']')
works.
John Elvin
User avatar
DavidNewton
Superstar
Posts: 464
Joined: 25 Mar 2014 11:46
Family Historian: V7

Re: Census indexing by year

Post by DavidNewton »

Thank you for the clarification jelv. As you surmised I did not get what Jane was saying.

David
Post Reply