Page 1 of 1
Determining if a Fact has any Witnesses
Posted: 31 Mar 2023 17:51
by macmcd
Hello all,
I'm trying to write a sentence template using TextIf to output text depending if a fact has anyone assigned to a witness role. As I'm relatively new to this, I'm struggling to find the correct data expression to determine if a fact has any witnesses so any help would be appreciated.
Regards,
Mac.
Re: Determining if a Fact has any Witnesses
Posted: 31 Mar 2023 17:55
by tatewise
Mac, have you looked at the standard facts to see how they conditionally output Fact Witness related text?
If that does not work for you then please explain in more detail what sentence structure you want to achieve.
However, in general, it is not possible to use TextIf(...) to determine if a Witness Role is in use.
Re: Determining if a Fact has any Witnesses
Posted: 01 Apr 2023 09:23
by macmcd
Thanks for the reply, Mike. Yes, I did look at some of the other facts sentences and they tend to use angled brackets to leave out unused roles. I am trying to list all the roles associated with a fact along these lines:
Present at the wedding were <{role=Witness} (witness);> <{role=mother of bride} (mother of the bride);> <{role=father of bride} (father of the bride);> etc.
Obviously, if there were no witness roles then I would be left with:
Present at the wedding were.
So I thought that I could use the TextIf expression to output the sentence if there are witnesses associated with a fact. I am unsure how to write a data expression that returns a true value if the fact has witnesses. Looking at
www.gedsite.com there is an expression that does what I want:
[W:+] is true only if there is at least one witness
However, I am unsure how to write this in FH.
Re: Determining if a Fact has any Witnesses
Posted: 01 Apr 2023 10:10
by tatewise
OK, so you only need to test for the existence of the 1st Fact Witness because you don't care how many or what Roles are involved but simply that one or more exist.
{=TextIf( Exists(%FACT._SHAR%), " Present at the wedding were ", )} should do it.
Re: Determining if a Fact has any Witnesses
Posted: 01 Apr 2023 12:10
by macmcd
Thanks Mike. That will determine if there is a witness and thus output the sentence however I run into the angle brackets problem again. Thus the sentence:
{=TextIf( Exists(%FACT._SHAR%), " Present at the wedding were <{role=Witness} (witness);> <{role=mother of bride} (mother of the bride);> <{role=father of bride} (father of the bride);>", )}
outputs as:
Present at the wedding were <{role=Witness} (witness);> <{role=mother of bride} (mother of the bride);> <{role=father of bride} (father of the bride);>
Therefore, I guess I would need to use TextIf(a role has a witness) for each role and CombineText to build the sentence. Is there an iterative way of doing this?
Re: Determining if a Fact has any Witnesses
Posted: 01 Apr 2023 12:32
by tatewise
No Mac, just use the expression exactly as I provided before any < angle brackets >
i.e.
{=TextIf( Exists(%FACT._SHAR%), " Present at the wedding were ", )}<{role=Witness} (witness);> <{role=mother of bride} (mother of the bride);> etc...
The TextIf(...) looks after the text phrase and each set of < angle brackets > looks after each witness Role.
Re: Determining if a Fact has any Witnesses
Posted: 01 Apr 2023 20:55
by macmcd
Thanks again Mike. That is a much simpler solution. Onto the next.