* 'Text from Source' in a Source entry for an event

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
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

'Text from Source' in a Source entry for an event

Post by quarlton »

Hi

Can anyone point me in the right direction with picking up 'Text From Source' from a Source entry on an event.

The following works, but I can't find 'Text from Source' anywhere.
Caveat: The following assumes that all the entries are populated. It fails if not fully populated, but that is a different issue :?

pi4 is pointing to a Source entry on an Individual's Birth event

Code: Select all

pi5:MoveToFirstChildItem(pi4)		            --pi5 Now points to 'Where Within Source'
strWherewithinsource = fhGetValueAsText(pi5)   --Pick up 'Where within Source' value

pi5:MoveNext()					--pi5 now points to 'Data Recorded' aka "Entry Date"

pi5:MoveNext()					--pi5 now points to 'Certainty Assessment' aka "Asessment"

pi5:MoveNext()					--pi5 now points to 'Note'

Many thanks

Dave
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: 'Text from Source' in a Source entry for an event

Post by Jane »

The clue as always is the Data Reference eg

Code: Select all

%FACT.SOUR[1].DATA.TEXT[1]%
So you need the second child of pi5 (it's one of the "odd things" in the gedcom standard, or just use

Code: Select all

ptr:MoveTo(pi4,'~.DATA.TEXT')
Personally I prefer to use that method as you can be sure exactly what item you are getting, imported gedcoms may not be in the same order or contain the same fields. I also makes the code much easier to work out.
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
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: 'Text from Source' in a Source entry for an event

Post by quarlton »

Many thanks for that Jane, it solves the problem.

However, how do we determine the correct data references?

Code: Select all

ptr:MoveTo(pi4,'~.DATA.TEXT')
To use that method I need to discover the references for the other items.
I looked in the various Help files but didn't see (or I didn't recognise) anything that would point me to picking that reference.

Obviously I'm missing something quite basic :?
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: 'Text from Source' in a Source entry for an event

Post by quarlton »

I've just some testing and keep failing :cry:

The full code for testing is as follows
See last 6 lines of comments to see what each ptr is returning

Code: Select all

pi  = fhNewItemPtr()	     --Points to INDI record
pi2 = fhNewItemPtr()	     --Points to BIRT entry
pi3 = fhNewItemPtr()	     --Points to Children of BIRT entry
ptr = fhNewItemPtr()		  --Points to 'Where within source'


--Move to the first individual's record
pi:MoveToFirstRecord('INDI')    		--Points to first INDI record

--Move to their BIRT entry
pi2:MoveTo(pi,"~.BIRT")               --pi2 Points to BIRT

--Step through the children until find a SOUR record
pi3:MoveToFirstChildItem(pi2)			--This will be DATE then PLACE then ADDRESS followed by 
                                      --any SOURces then NOTE

while not pi3:IsNull() do	
		strTagType=fhGetTag(pi3)  	  	--Pick up the tag type
		if strTagType == 'SOUR' then	   --Check the TagType to see if it's SOUR. 
											       --If reach here then p3 should be pointing at the 
											       --Source for birth entry
			ptr:MoveTo(pi3,'~DATA.TEXT') --Now we want to pick up the value of 'Text from source'
												  --However, I find that at this point we have:
												  --pi points to the Individual
												  --pi2 points to the Birth entry for the Individual
												  --pi3 points to the Source entry for the Birth entry
												  --ptr returns (null)
		end
pi3:MoveNext()

end
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
DavidNewton
Superstar
Posts: 464
Joined: 25 Mar 2014 11:46
Family Historian: V7

Re: 'Text from Source' in a Source entry for an event

Post by DavidNewton »

quarlton wrote:...
To use that method I need to discover the references for the other items.
I looked in the various Help files but didn't see (or I didn't recognise) anything that would point me to picking that reference.

Obviously I'm missing something quite basic :?
When editing a script the menu item Edit>Insert Data Reference will give you access to all.

David
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: 'Text from Source' in a Source entry for an event

Post by tatewise »

David is correct, that gives the same Data Reference Assistant as everywhere else in FH.
You use the popular names to find the data item and the Gedcom tags appear at the top.

As Jane has advised, you need to get out of the habit of using MoveToFirstChildItem() and MoveNext() where inappropriate, as tags are not necessarily ordered the way you might think.

Use pi3:MoveTo(pi,'~.BIRT.SOUR') to select 1st Source Citation.
Then use pi3:MoveNext('SAME_TAG') to loop through Source Citations while pi3:IsNotNull() do.

You are also overlooking the dot between tilde and tag, c.f. ~.DATA
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: 'Text from Source' in a Source entry for an event

Post by quarlton »

Many thanks to Jane, David and Mike

Between the three of you things have become much clearer.

Dave
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
Post Reply