* Expression guidance please
Expression guidance please
I want to add a icon to my Diagram Tree View, dependant upon the Birth OR Baptism place but all my expression attempts are rejected as "Expression not valid". For example, starting just with Birth:
ContainsText(%INDI.BIRT[1].PLAC>%,"Devon",FULL)
What should I be writing?
Thanks
ContainsText(%INDI.BIRT[1].PLAC>%,"Devon",FULL)
What should I be writing?
Thanks
Tracing the Devon Bellamy family along with their partners.
- tatewise
- Megastar
- Posts: 28435
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Expression guidance please
FULL is not a valid 3rd parameter. Check the function Help page.
Also, the outermost function needs a leading = sign.
Also, the outermost function needs a leading = sign.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Expression guidance please
I am puzzled. I don't quite understand how ContainsText and = can work in the same expression.
None of the examples I have studied in the KB use it, but I am new to this.
None of the examples I have studied in the KB use it, but I am new to this.
Tracing the Devon Bellamy family along with their partners.
- tatewise
- Megastar
- Posts: 28435
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Expression guidance please
See FHUG Knowledge Base Understanding Functions where the The Basics section explains where the = sign should and should not appear. The = sign indicates to the FH expression processor to expect a function name.
Your function should be:
=ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ) if it is NOT within the parentheses of another Function.
ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ) if is within the parentheses of another Function.
e.g. =TextIf( ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ), "Yes", "No" )
Understanding Expressions has many examples where functions have a leading = sign and many that do not for the reasons given above.
Your function should be:
=ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ) if it is NOT within the parentheses of another Function.
ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ) if is within the parentheses of another Function.
e.g. =TextIf( ContainsText( %INDI.BIRT[1].PLAC>%, "Devon", STD ), "Yes", "No" )
Understanding Expressions has many examples where functions have a leading = sign and many that do not for the reasons given above.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Expression guidance please
You put the equals sign at the beginning of the expression, like this:
You can see some examples in the online help, here:
https://www.family-historian.co.uk/help ... stext.html
If you are using a function in an expression in a condition to display an Icon, you will need the equals sign. If you are just basing it on a fact, you won't need it, just the Data Reference. Have a look at some of the examples from my tree below:
Hope this helps. It can be a bit hit and miss while you develop complex expressions, just start simple and ask if you get stuck.
EDIT: Posted the same time as Mike, above, who explains it better
Code: Select all
=ContainsText(%INDI.BIRT[1].PLAC>%,"Devon",STD)
https://www.family-historian.co.uk/help ... stext.html
If you are using a function in an expression in a condition to display an Icon, you will need the equals sign. If you are just basing it on a fact, you won't need it, just the Data Reference. Have a look at some of the examples from my tree below:
Hope this helps. It can be a bit hit and miss while you develop complex expressions, just start simple and ask if you get stuck.
EDIT: Posted the same time as Mike, above, who explains it better
Adrian Cook
Researching Cook, Summers, Phipps and Bradford, mainly in Wales and the South West of England
Researching Cook, Summers, Phipps and Bradford, mainly in Wales and the South West of England
- AdrianBruce
- Megastar
- Posts: 2107
- Joined: 09 Aug 2003 21:02
- Family Historian: V7
- Location: South Cheshire
- Contact:
Re: Expression guidance please
My problem with the above is that it's just a recipe, and I'm not good at remembering recipes that I don't understand.One common misunderstanding is whether to include or exclude the leading = sign on the Function name.
- If the Function is NOT within the parentheses of another Function then the = sign is required.
- If the Function is within the parentheses then the = must be omitted.
Can anyone explain why FH is happy with no = within parentheses, but needs a = outside? For instance
=CalcDate(Year(%INDI.BIRT.DATE%), 10)
doesn't have one on Year in that place - inside () - but CalcDate does need one? Is it to distinguish CalcDate from something else? Such as....?
Adrian
- tatewise
- Megastar
- Posts: 28435
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Expression guidance please
Adrian, in some expressions (such as Sentence Templates, Diagram Text Schemes, and Report Heading Text) the items may be any of three types:
Otherwise INDI.BIRTH.DATE or CalcDate( ... ) would get taken as plain text.
When there is a syntax error, FH often displays parts of an expression in plain text when they are supposed to be Data References or Functions.
Inside the parentheses of a Function, the parameters that are plain text must be enclosed in single or double quotes.
Other parameters can be numbers or data references or functions which now don't need the = sign to differentiate them.
- Data Reference enclosed in %, e.g. %INDI.BIRT.DATE%
- Function starting with = sign, e.g. =CalcDate( ... )
- Plain text that can be anything.
Otherwise INDI.BIRTH.DATE or CalcDate( ... ) would get taken as plain text.
When there is a syntax error, FH often displays parts of an expression in plain text when they are supposed to be Data References or Functions.
Inside the parentheses of a Function, the parameters that are plain text must be enclosed in single or double quotes.
Other parameters can be numbers or data references or functions which now don't need the = sign to differentiate them.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Expression guidance please
Thanks everyone. Forum replies always seem much easier to understand than reading the KB and the examples.
I am now struggling trying to add the OR operator to test if the both the Birth or Baptism place are in Devon.
I have tried to find the correct syntax for the expression and my several attempts have all been invalid, including this:
=ContainsText (%INDI.BIRT.PLAC>%,"Devon",STD) or ContainsText (%INDI.BAPM[1].PLAC>%,"Devon",STD)
I am now struggling trying to add the OR operator to test if the both the Birth or Baptism place are in Devon.
I have tried to find the correct syntax for the expression and my several attempts have all been invalid, including this:
=ContainsText (%INDI.BIRT.PLAC>%,"Devon",STD) or ContainsText (%INDI.BAPM[1].PLAC>%,"Devon",STD)
Tracing the Devon Bellamy family along with their partners.
- tatewise
- Megastar
- Posts: 28435
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Expression guidance please
Peter, if you inspect Understanding Expressions closely enough you will examples that are similar to your requirements involving or and and operators.
Clue: They all start with =IsTrue
Clue: They all start with =IsTrue
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Expression guidance please
Thanks Mike. I hadn't realised the or had to pair with an IsTrue
Tracing the Devon Bellamy family along with their partners.
- AdrianBruce
- Megastar
- Posts: 2107
- Joined: 09 Aug 2003 21:02
- Family Historian: V7
- Location: South Cheshire
- Contact:
Re: Expression guidance please
Ah - thanks very much Mike. I think my analytical (or pedantic ) mind was missing the "plain text" classification. Once you said that (which I suspect I was a long way from realising) then the three cases fall into place.tatewise wrote: ↑11 Apr 2023 23:00 Adrian, in some expressions (such as Sentence Templates, Diagram Text Schemes, and Report Heading Text) the items may be any of three types:
- Data Reference enclosed in %, e.g. %INDI.BIRT.DATE%
- Function starting with = sign, e.g. =CalcDate( ... )
- Plain text that can be anything.
Yes that flip as you enter between the parentheses made little sense to me without the threefold classification and the "in some expressions" background. I could quite happily use the "Inside the parentheses" constructions on the outside as well. But (a) there might be some issue I've not thought of and (b) if I think of a typical simple line in a diagram text scheme like:
Code: Select all
C: %INDI.CENS[1+].DATE:YEAR% %INDI.CENS[1+].PLAC:SHORT%
So yes, thanks for that Mike - all I have to do now is remember where I've filed this.
Adrian
Re: Expression guidance please
Now happily playing with expressions in diagrams
One comment, which might have been mentioned before, the entry box is too small for more than one expression.
I ended up working in Notepad and then cutting and pasting.
One comment, which might have been mentioned before, the entry box is too small for more than one expression.
I ended up working in Notepad and then cutting and pasting.
Tracing the Devon Bellamy family along with their partners.
- tatewise
- Megastar
- Posts: 28435
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Expression guidance please
Peter, there is a longstanding 5-year-old Wish List Ref 545 Edit window for short Text fields that you can Vote for, and covers all short text fields, data fields, template fields, etc.
Yes, the workaround is to use something like Notepad which has the advantage that you can structure the expression over several lines to see that brackets are in balanced pairs and examine complex functions more clearly. Then remove the newline characters before pasting it into the template box.
Yes, the workaround is to use something like Notepad which has the advantage that you can structure the expression over several lines to see that brackets are in balanced pairs and examine complex functions more clearly. Then remove the newline characters before pasting it into the template box.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Expression guidance please
Thanks Mike added my vote.
Tracing the Devon Bellamy family along with their partners.