Functions (all)

TextPart

Function Name:
TextPart
Description:

Although designed primarily to help with the presentation of place information in reports and elsewhere, this function can however be used with any text fields.  It returns one or more parts of any comma-separated text.  It can also be used to 'tidy' comma-separated text by removing extra commas.  And finally it can reverse the items in a comma-separated list.

See also Section.

Minimum FH Version:
6.0
No. of Parameters:
3
Return Type:
Text
Parameter 1:
String.  The input text
Parameter 2:
Number. The first section to return.  Assuming parameter 3 is the default (1), a value of 1 for this parameter will return the first section of the text (that is, up to the first comma).  A value of 2 would return the second (between the first and second commas); and so on  Negative values can be used to reference sections from the end.  -1 references the last section.  -2 references the second last section.  And so on. 
Parameter 3:
Number. Defaults to 1 if not supplied.  The number of sections to return.  Negative values are not allowed.  0 is a special value which means "return all remaining sections".  Note: Strictly-speaking, this parameter specifies the number of sections that would be returned if you did not apply tidying or reverse (see Parameter 4).
Parameter 4:

This parameter can be used to modify the behaviour of the function.

STD
The default value if not supplied.  The text section is returned unmodified.
TIDY
Commas separating empty section sections are removed, and spaces between sections are tidied.  For example, ",one,,  ,,three ,four,,," would become "one, three, four" after being tidied.  This option has no effect if only one section is requested in parameter 3.
REV
The comma-separated sections are reversed.  For example, "one, two, three" would become "three, two, one". This option also has no effect if only one section is requested in parameter 3.
TIDY_REV
Combines the functionality of TIDY and REV.
Examples:

Assuming the input text (%INDI.BIRT.PLAC%) contains "one, two, three, four, five, six, seven, eight", the following function calls will return the values shown:
=TextPart(%INDI.BIRT.PLAC%, 1, 1) one
=TextPart(%INDI.BIRT.PLAC%, 2) two
=TextPart(%INDI.BIRT.PLAC%, 4, 3) four, five, six
=TextPart(%INDI.BIRT.PLAC%, 5, 0) five, six, seven, eight
=TextPart(%INDI.BIRT.PLAC%, -1) eight
=TextPart(%INDI.BIRT.PLAC%, -3, 2) five, six
=TextPart(%INDI.BIRT.PLAC%, -2, 0) one, two, three, four, five, six, seven

Assuming the input text (%INDI.BIRT.PLAC%) contains "one, two,,, five, six, seven, eight", the following function calls will return the values shown:
=TextPart(%INDI.BIRT.PLAC%, 1, 0, TIDY) one, two, five, six, seven, eight
=TextPart(%INDI.BIRT.PLAC%, 3, 5) ,, five, six, seven
=TextPart(%INDI.BIRT.PLAC%, 3, 5, TIDY) five, six, seven
=TextPart(%INDI.BIRT.PLAC%, 3, 5, TIDY_REV) seven, six, five