* Help with box condition expression please

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
RS3100
Famous
Posts: 240
Joined: 05 Nov 2020 12:16
Family Historian: V7
Location: Hertfordshire, UK

Help with box condition expression please

Post by RS3100 » 09 Jun 2022 14:31

I have been using Jane's Gedmatch custom event and query for some time, and have a DNA helix icon set against diagram boxes for DNA matches to myself or other primary links (the person whose DNA test is matched against by the individual in the diagram box) using the expression %INDI.EVEN-GEDMATCH% as the box condition, as suggested by Jane in her article about the custom event and query at

https://www.taubman.org.uk/family/wp/20 ... historian/

I am now attempting to add further diagram box conditions to apply an additional icon to identify the primary link or home person being matched against, e.g. my brother, other relative, or myself.

But I am struggling somewhat with the concept of more complex expressions, despite reading the FH help and knowledge base articles on the subject. Having spent some time trying to get my head around what I am trying to achieve and referring to the expressions used in Jane's Gedmatch query to populate the columns, I have been experimenting with various constructs without much success. I have finally succeeded in creating an expression that FH accepts as valid, but it isn't actually doing anything:

=IsTrue(Exists(%INDI.EVEN-GEDMATCH%) and (GetLabelledText(%FACT.NOTE2%,"Primary Link:") = "1"))

I am trying to check for the presence of a Gedmatch event against the individual, and then check the identity of the primary link contained in the Gedmatch event note, i.e. "Primary Link: 1" is me, "Primary Link: 2" is my brother, etc. I am assuming that by creating separate conditions matching to Primary Link: 1 or 2, etc. that I can display an additional box icon to identify the relevant person.

The =GetLabelledText(%FACT.NOTE2%,"Primary Link:") expression is used to populate the home person's name in the Gedmatch query, but nested within =Record(TextToNumber(GetLabelledText(%FACT.NOTE2%,"Primary Link:")),"I") which I can see is used to return the actual name of the person from their record ID and populate the query column accordingly. But as the record ID should suffice for my purposes, I shouldn't need to use =TextToNumber.

Can anyone point me in the right direction or explain where I am going wrong please?

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

Re: Help with box condition expression please

Post by tatewise » 09 Jun 2022 14:47

Yes, the problem is your use of %FACT.NOTE2%.

In the Query, the context is already established as the EVEN-GEDMATCH fact, so %FACT.NOTE2% refers to its Note.
( It actually refers to the Note of every Fact, but the Rows tab filter limits its scope to just the EVEN-GEDMATCH facts. )

But in a Box Condition, the context is the Individual, so just as you use %INDI.EVEN-GEDMATCH% to identify the existence of the fact you must use %INDI.EVEN-GEDMATCH.NOTE2% to reference its Note.

You don't even need to test for the EVEN-GEDMATCH fact existence, so the condition expression becomes simply:

=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH.NOTE2%, "Primary Link:" ) = "1" )

This assumes that there is only one EVEN-GEDMATCH fact per Individual record.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
RS3100
Famous
Posts: 240
Joined: 05 Nov 2020 12:16
Family Historian: V7
Location: Hertfordshire, UK

Re: Help with box condition expression please

Post by RS3100 » 09 Jun 2022 16:02

Ah, thanks Mike. I did think that referencing the correct note might be the problem, but wasn't sure how to resolve it.

However, there are two or more Gedmatch facts for many individual records, because as expected, my brother and I both share matches to many individuals, and I create a separate fact for each primary link to record the relevant information on each match against that person, i.e.me or him - or other relatives that I have matching information for, against the same individual.

So how would I check for separate instances of the fact note?

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

Re: Help with box condition expression please

Post by tatewise » 09 Jun 2022 16:34

I suspected that is what you were going to say, which is why I added that last assumption as a condition.

The way to refer to instances of facts is the same as usual by adding a numerical index:
%INDI.EVEN-GEDMATCH[1].NOTE2% for 1st instance, or %INDI.EVEN-GEDMATCH.NOTE2% as the default is [1]
%INDI.EVEN-GEDMATCH[2].NOTE2% for 2nd instance
%INDI.EVEN-GEDMATCH[3].NOTE2% for 3rd instance
and so on...

The snag is that potentially any of them can have "Primary Link:" values of "1" or "2" or whatever.
So you must have a Box Condition to cater for every possibility.

For you as the Primary Link these Box Conditions may be needed and each enables your icon:
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[1].NOTE2%, "Primary Link:" ) = "1" )
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[2].NOTE2%, "Primary Link:" ) = "1" )
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[3].NOTE2%, "Primary Link:" ) = "1" )
repeated for up to the largest number of GEDMATCH facts that may exist in any one Individual record, unless you are certain that if you are the Primary Link that will be the 1st GEDMATCH fact, in which case, only the 1st instance needs a Box Condition.

For your brother as the Primary Link these Box Conditions may be needed and each enables his icon:
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[1].NOTE2%, "Primary Link:" ) = "2" )
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[2].NOTE2%, "Primary Link:" ) = "2" )
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[3].NOTE2%, "Primary Link:" ) = "2" )
repeated for up to the largest number of GEDMATCH facts that may exist in any one Individual record, unless you are certain that if he is the Primary Link that will be in the 1st or 2nd GEDMATCH fact, in which case, only those two need a Box Condition.

That must continue for whatever other Primary Links you may have recorded for which you need icons.

BTW: The Box Condition can be one complex expression if you wish:
=IsTrue( GetLabelledText( %INDI.EVEN-GEDMATCH[1].NOTE2%, "Primary Link:" ) = "2"
or GetLabelledText( %INDI.EVEN-GEDMATCH[2].NOTE2%, "Primary Link:" ) = "2"
or GetLabelledText( %INDI.EVEN-GEDMATCH[3].NOTE2%, "Primary Link:" ) = "2" )
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
RS3100
Famous
Posts: 240
Joined: 05 Nov 2020 12:16
Family Historian: V7
Location: Hertfordshire, UK

Re: Help with box condition expression please

Post by RS3100 » 09 Jun 2022 19:06

Thanks again Mike. I have it working now, after a fashion as I'll explain. But I never would have done it without your help, because I couldn't get your expression to work at first either.

It turns out to be due to the fact that I used tabs between the label and the text field in my fact notes. Having removed the tabs from a couple of the notes, the icons appear against the related individual's boxes as desired.

However, I'm not sure if that is a bug or by design?

I'm aware that the GetLabelledText function description states that "paragraphs within tables (in rich text notes) are not searched or matched by this function". When I created the notes, I used tabs to separate the label and the text (after the colon) simply to make the note easier to read, with all the label text aligned. I tested that against the Gedmatch query (which uses the GetLabelledText function for several columns) and it populated all the required fields in the query as expected. So I now have quite a few rich text Gedmatch fact notes containing tab characters.

But although that works to populate the fields in the query, it fails with the box expression. If I remove the tabs and use one or more space characters between the label colon and the field text instead, it works.

So, should that be reported to CP as a bug, or does the use of tabs in a rich text note constitute "a table", and for some reason the function when used in a query just happens to work, albeit unintentionally?

It seems that I am going to have to edit all those notes to remove the tabs if I want this to work. Can your Search and Replace plugin handle that, or am I going to have to manually edit them one at a time?

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

Re: Help with box condition expression please

Post by tatewise » 09 Jun 2022 19:29

I reported that problem to CP in Feb 2021 as:
#244746 GetLabelledText(…) now does not discard tabs between label and text.
In FH V5/V6 labelled text such as Latitude = 32.2002948 returned '32.2002948' regardless of any tab characters.
In FH V7 if any tab character exists between the label and the text then it is included in the returned text.
Space characters are still discarded so why not tab characters or any other non-printing characters?
This has upset at least one of my Plugins and could upset Queries and Reports, etc.
Maybe you could report the same problem to CP again.

In the Query the Primary Link: text is being returned as tab digit.
The TextToNumber(...) function then ignores the tab and converts the digit text to an integer number to use as Record Id.

In the Box Condition the Primary Link: text is also being returned as tab digit, but you test against just a digit.

I suspect you would prefer to retain the tidy tab in the Note, so the tab needs to be inserted into the Box Condition.
In "Primary Link:" ) = "1" the tab must go after the colon or before the 1.
To insert the tab, copy & paste a tab from somewhere else, as it cannot be typed into the Box Condition directly.

It is possible to use the Search and Replace plugin to convert the tab to space in those Primary Link: notes.
I can explain how if you wish to go down that route.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
RS3100
Famous
Posts: 240
Joined: 05 Nov 2020 12:16
Family Historian: V7
Location: Hertfordshire, UK

Re: Help with box condition expression please

Post by RS3100 » 09 Jun 2022 21:21

Thanks Mike, you are right that I would prefer to keep the formatting in the notes.

I will have a go at copying and pasting a tab into the expression tomorrow, and will also report the issue to CP.

Thank you again for your help.

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

Re: Help with box condition expression please

Post by tatewise » 10 Jun 2022 09:09

There is another option staring us in the face by using Box Condition expressions such as:

=IsTrue( TextToNumber( GetLabelledText( %INDI.EVEN-GEDMATCH[1].NOTE2%, "Primary Link:" ) ) = 1 )

=IsTrue( TextToNumber( GetLabelledText( %INDI.EVEN-GEDMATCH[3].NOTE2%, "Primary Link:" ) ) = 2 )

Then it does not matter whether you have a tab or space between the label and the digit :D
You also don't need to insert tab characters into the expression.
This workaround is only effective because the value after each label is a number.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
RS3100
Famous
Posts: 240
Joined: 05 Nov 2020 12:16
Family Historian: V7
Location: Hertfordshire, UK

Re: Help with box condition expression please

Post by RS3100 » 10 Jun 2022 09:52

That is a much more elegant solution Mike! All working as expected. Thank you again :)

Post Reply