Main Help → GENerel Reference → String Conditional Commands
The ifStr command is used to define string comparison conditional blocks. The use of ifStr is always a string comparison. If you use just if and either comparison object is not a number, the conditional will automatically be converted to ifStr and then done as a string comparison as described here. The format of a conditional block is:
ifStr (string1) (op) (string2)
(block of commands if string comparison is true)
.
else ifStr (string1)
(block of commands based on converting this uniary conditional
to "ifStr (string1) is true" including special options
for (string1) in ' is ' comparisons)
.
else if (num1) (op) (num2)
(i.e., numeric "else if" blocks can be used in an ifStr block)
.
else
(block of commands if no prior condition is true)
endif
where there can be any number of conditionals and each can be a string comparison or a numeric comparison.
String comparison conditionals compare (string1) to (string2) with the following comparison operators for (op):
=: true if (string1) is equal to (string2) by case-insensitive comparison.== : true if (string1) is equal to (string2) by case-sensitive comparison (i.e., two equals signs means more equal than one equals sign).!= or <> : true if (string1) is not equal to (string2).> : true if (string1) is alphabetically greater than (string2).>= : true if (string1) is alphabetically greater than or equal to (string2).< : true if (string1) is alphabetically less than (string2).<= : true if (string2) is alphabetically less than or equal to (string2).= for case-insensitive comparison. When writing templates for browser styles, however, this comparison looks for various keywords described below but will revert to a case-insensitive compare if no keyword is found.
When writing templates for browser styles, the comparison operator ' is ' looks for special keywords in (string2) that can check various things:
(string1) is validlink: true if (string1) is a valid record ID for a GEDCOM record in the current file.(string1) is notvalidlink: true if (string1) is not a valid record ID for a GEDCOM record in the current file.(string1) is here: true if (string1) is a tag that exists subordinate to the current data being formatted. You can check multiple tags by (string1) being tag1|tag2|tag3. This form is true if any one of those tags exists in subordinate data.(string1) is nothere: true if (string1) is a tag that does not appear subordinate to the current data being formatted. You can check multiple tags by (string1) being tag1|tag2|tag3. This form is true if any one of those tags is not in the subordinate data (i.e., true if all are in the subordinate data).(string1) is htmldiv: true if (string1) begins in <div> and ends in </div>, which is the style used by GEDitCOM II to allow html content in GEDCOM data. It works even if the initial <div> has attributes.Alternatively, if (string2) is "true" or "false", an ' is ' conditional instead looks for the following special keywords in (string1):
tagexists is true: true if current data being formatted corresponds to data that exists in the file.tagexists is false: true if current data being formatted corresponds to a tag that does not exist in the file.more is true: true if current data being formatted has additional subordinate data that has not yet been formatted.more is false: true if current data being formatted has no additional subordinate data left to be formatted.inGroupBox is true: true if current template is subordinate to a template that started a group box cell.inGroupBox is false: true if current template is not subordinate to a template that started a group box cell.printing is true: true if display is being formatted for printing.printing is false: true if display is being formatted for the screen.If none of the above keywords are used, an ' is ' operator does a standard string comparison. In other words, it is true if (string1) is equal to (string2) by case-insensitive comparison.
Some string functions can be used to implement other types of useful string comparisons. For example:
if offset(s1\string)>0 - is true if the string contains the string s1.ifstr chars("\"&length(s1)&"\string")=s1 - is true if string starts with the string s1 (case insensitive, use == to make it case sensitive).ifstr chars((length(string)-length(s1)+1)&"\string")=s1 - is true if string ends with the string s1 (case insensitive, use == to make it case sensitive).