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?
* GetLabeledText check if empty
Re: GetLabeledText check if empty
Yes, the statement is wrong. I should have used:
{=TextIf((GetLabelledText(%FACT.NOTE2%,"Impost: ")=""),"text1", "text2")}
Sorry for my dumb question.
{=TextIf((GetLabelledText(%FACT.NOTE2%,"Impost: ")=""),"text1", "text2")}
Sorry for my dumb question.
- Jane
- Site Admin
- Posts: 8442
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: GetLabeledText check if empty
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.
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."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
Re: GetLabeledText check if empty
That is a useful answer! So the question must have been useful because it flushed it out!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.
David
Running FH 6.2.7. Under Wine on Linux (Ubuntu 22.04 LTS + LXDE 11)
Running FH 6.2.7. Under Wine on Linux (Ubuntu 22.04 LTS + LXDE 11)
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: GetLabeledText check if empty
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.
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
Re: GetLabeledText check if empty
@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.
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.