* GetLabeledText check if empty

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
JoopvB
Superstar
Posts: 328
Joined: 02 May 2015 14:32
Family Historian: V7

GetLabeledText check if empty

Post by JoopvB »

I am in the process of changing over to GetLabeledText for my "meta fields" in the sentence definition of the various fact types. Overall this is going very well but I've run into a small problem. When I test whether a "meta field" has no input, the test doesn't work.

I tried:
{=TextIf(Exists(GetLabelledText(%FACT.NOTE2%,"Impost: ")),"text1", "text2")}

I can imagine that the CR at the end of the line makes the test fail. If so, what other test can be used to accomplish conditional text as depending on the GetLabeledText approach? Or, am I overlooking the obvious and is the statement just wrong?
avatar
JoopvB
Superstar
Posts: 328
Joined: 02 May 2015 14:32
Family Historian: V7

Re: GetLabeledText check if empty

Post by JoopvB »

Yes, the statement is wrong. I should have used:

{=TextIf((GetLabelledText(%FACT.NOTE2%,"Impost: ")=""),"text1", "text2")}

Sorry for my dumb question.
User avatar
Jane
Site Admin
Posts: 8513
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: GetLabeledText check if empty

Post by Jane »

No such thing as a dumb question and thanks for posting your solution as well.

The reason is that Exists() checks for a Data Item (in Lua terms a pointer) so checking a Text string always fails.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
davidf
Megastar
Posts: 951
Joined: 17 Jan 2009 19:14
Family Historian: V6.2
Location: UK

Re: GetLabeledText check if empty

Post by davidf »

Jane wrote:No such thing as a dumb question and thanks for posting your solution as well.

The reason is that Exists() checks for a Data Item (in Lua terms a pointer) so checking a Text string always fails.
That is a useful answer! So the question must have been useful because it flushed it out!
David
Running FH 6.2.7. Under Wine on Linux (Ubuntu 22.04 LTS + LXDE 11)
User avatar
tatewise
Megastar
Posts: 28403
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: GetLabeledText check if empty

Post by tatewise »

An alternative (more conventional & more efficient) approach is to ensure one of the following exists in the Note field:

Impost: text1

Impost: text2

Impost:

Then {=GetLabelledText(%FACT.NOTE2%,"Impost: ")} will display either text1 or text2 or nothing.

Using this method the text can take any number of different values.
Whereas your technique gets extremely cumbersome if there are more than two possible text values.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
JoopvB
Superstar
Posts: 328
Joined: 02 May 2015 14:32
Family Historian: V7

Re: GetLabeledText check if empty

Post by JoopvB »

@Mike

Yes, and that's what I use. But, I see now my question was confusing. In addition to what you (and I ) use to get the "meta field" input, I also use the fact that there is an input to the "meta field" to decide which text to use on a different position in the sentence. Hence the test.
Post Reply