Functions (all)

CombineText_AB

Function Name:
CombineText_AB
Description:
This function is typically used in diagram text schemes. It can be used with in different ways, depending on the type of format string which is passed as the third parameter.  The type 1 format string allows you to combine 2 items of text (A and B) by adding an optional prefix and/or suffix.  You can also optionally supply text to separate A and B if not empty, and you can optionally supply alternative text to use if both A and B are empty.  The type 2 format string allows you to output text depending on whether the 2 items of text (A and B) are empty or not.

See also CombineText, ExistsText, NotExistsText and ForceText.

Minimum FH Version:
7
No. of Parameters:
3
Return Type:
Text
Parameter 1:
The first item of text (the 'A' text).
Parameter 2:
The second item of text (the 'B' text)
Parameter 3:
A format string.  There are 2 types of format string.  Type 1 starts with '1'.  Type 2 starts with '2'.
Type 1 Format String
The format string must start with digit '1' followed by a separator character ('#' in the example below) that will be used to separate out the remaining sections of the format string.  The rest of the string are the (optional) 'sections' that are used as follows:

section 1 Prefix to be output if either A or B are not empty
section 2 Separator to be output if both A and B are not empty
section 3 Suffix to be output if either A or B are not empty
section 4 Alternative text to be output if both A and B are empty

Type 2 Format String
The format string must start with digit '2' followed by a separator character (e.g. '|') that will be used to separate out the remaining sections of the format string.  The rest of the string are the (optional) 'sections' that are used as follows:

section 1 Text to be output if A only is not empty.  If this text contains the special code "#A" (without the quotes), that code will be substituted with the value of the A string.
section 2 Text to be output if both A and B are not empty.  If this text contains the special code "#A" (without the quotes), that code will be substituted with the value of the A string.  If this text contains the special code "#B" (without the quotes), that code will be substituted with the value of the B string.
section 3 Text to be output if B only is not empty.  If this text contains the special code "#B" (without the quotes), that code will be substituted with the value of the B string.
section 4 Text to be output if both A and B are empty

Strictly-speaking you can insert #A and #B into any section. However, doing so will have no effect (they will simply be removed) if corresponding text string is empty.

Examples (Type 1):

%INDI.OCCU% =CombineText_AB(%INDI.OCCU.DATE:YEAR%,%INDI.OCCU.PLAC:TIDY%,"1#(#, #)")

%INDI.OCCU% =CombineText_AB(%INDI.OCCU.DATE:YEAR%,%INDI.OCCU.PLAC:TIDY%,"1#[#; #]#(no date/place)")

If used in a diagram text scheme, for occupations farmer (in 1985, London), engineer (in August 1987), labourer (Dorset), and doctor (no date or place supplied), the first example would output this:

farmer (1985, London)
engineer (1987)
labourer (Dorset)
doctor

If the second example were used instead, with the same set of occupations and dates/places, this would be output instead:

farmer [1985, London]
engineer [1987]
labourer [Dorset]
doctor (no date/place)

Example (Type 2):

=CombineText_AB(%INDI.OCCU.DATE%,%INDI.OCCU.PLAC%,"2|Occ. date only (#A)|Occ. date & place|Occ. place only|Neither Occ. data nor place")