* Need help with Expression: Distinguishing between WWI and WWII

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
APerson
Diamond
Posts: 60
Joined: 19 Jan 2022 03:23
Family Historian: V7
Location: New Jersey, USA
Contact:

Need help with Expression: Distinguishing between WWI and WWII

Post by APerson » 05 Dec 2022 21:41

Hi All,

I’m trying to create an expression to generate an icon for military service in WWI and/or WWII; a separate icon should appear for each war. I’m running into a problem in that I currently have two expressions:
=IsTrue(ContainsText(%INDI._ATTR-MILITARY_SERVICE%,"ww1",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[2]%,"ww1",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[3]%,"ww1",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[4]%,"ww1",STD))
and
=IsTrue(ContainsText(%INDI._ATTR-MILITARY_SERVICE%,"wwii",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[2]%,"wwii",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[3]%,"wwii",STD) or ContainsText(%INDI._ATTR-MILITARY_SERVICE[4]%,"wwii",STD))
The problem is that each searches for the text “wwi” and because “wwi” is contained within “wwii,” two icons (for each war) appear when only wwii should appear. I’m sure that the solution to prevent this from happening would be to add an additional item to each expression so that only the appropriate icon appears based on the year. For example, the WWII icon should only appear if the military service occurred between 1940 and 1945. Unfortunately, I have been trying, unsuccessfully, to add the correct code to the expression.

Thanks for your help!
Jeff La Marca

Want to cite your sources simply while maintaining accuracy?
Visit Simple Citations

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

Re: Need help with Expression: Distinguishing between WWI and WWII

Post by tatewise » 05 Dec 2022 23:26

The general format for each instance of the fact would be:
(ContainsText(%INDI.FACT%,"wwi",STD) and ( Year(%INDI.FACT.DATE%) > 1913 ) and ( Year(%INDI.FACT.DATE%) < 1919 ))
and
(ContainsText(%INDI.FACT%,"wwii",STD) and ( Year(%INDI.FACT.DATE%) > 1938 ) and ( Year(%INDI.FACT.DATE%) < 1946 ))

You might think %INDI.FACT.DATE:YEAR% would be OK but does not cope with as many Date formats as the Year(...) function.

Substitute FACT with _ATTR-MILITARY_SERVICE and add indices [2], [3], etc, as necessary.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
APerson
Diamond
Posts: 60
Joined: 19 Jan 2022 03:23
Family Historian: V7
Location: New Jersey, USA
Contact:

Re: Need help with Expression: Distinguishing between WWI and WWII

Post by APerson » 06 Dec 2022 05:35

Thanks, Mike, It worked!
Jeff La Marca

Want to cite your sources simply while maintaining accuracy?
Visit Simple Citations

Post Reply