


When implementing interactive applications, the user input and the output values usually have to be converted or prepared. There are two types of string functions:
- functions that have a string as argument and a string as result (<string function>)
- functions that have a string as argument and a numeric value as result (<strpos function>)
The following list of examples illustrates the way string functions work.


In string functions the NULL value is always handled like an empty string. The repeat operator (n) can only be used for single characters. The specified character is repeated as often as is determined by the number defined by the numeric expression.
The function HEX can be applied to any string expression. It provides a string twice as long in hexadecimal notation.
The function CHR supplies the character for the given numeric value that corresponds to the CHAR representation of this value. If something other than a numeric value is specified or if there is no CHAR representation for the numeric value, CHR returns the NULL value as result. The inverse function to CHR is the function ORD. It returns the corresponding numeric value for a character.
The concatenation (&) as well as the functions UPPER, LOWER, SUBSTR, TRIM, LENGTH, STRPOS, SPAN, BREAK, and CHANGE can also be applied to variables and arbitrary string expressions.
With the function TRIM, the specified character is removed from both ends of a string. With an additional argument, this can be restricted to one of the two ends.
With the function PAD, a string is filled with blanks to the specified length. With an additional argument it can be specified whether this should be done on the left or the right or on both sides.
The function INDEX can only be applied to vector slices. From the specified vector slice it supplies the index of the first vector component that has the desired value. If no such vector component is found, INDEX provides NULL as result.
The function STRPOS scans a variable value for the specified string. If it is found, STRPOS returns the starting position as result. Otherwise STRPOS returns NULL. The starting position of the search can be specified.
The function SPAN returns the position of the first character of the first string not contained in the second string. The starting position of the search can be specified.
The function BREAK returns the position of the first character of the first string contained in the second string. The starting position of the search can be specified.
CHANGE replaces the second string within the first string by the third string. By omitting the third string, the second string within the first string is deleted. All arguments can also be specified as variables or string expressions.
The function CHANGE assigns the number of arguments that have been changed to the $ variable $ITEMS.
The functions TOKENIZE and SEPARATE fill a vector with the fields of a string. The fields are separated by the characters contained in the second argument. Consecutive separating characters are interpreted by TOKENIZE like one separating character, by SEPARATE, however, as fields with the value NULL. After the call, the system variable $ITEMS contains the number of fields detected.
With the FORMAT function numeric values can be flexibly prepared for output according to a predetermined pattern. The first argument of the FORMAT function can be a number, a variable or an arbitrary arithmetic expression:

Each '9' in the mask marks the position of a digit. The first point or comma (from the right to the left) is interpreted as position and representation of the decimal sign. If the decimal sign is not to be represented by a point or a comma, the places after the decimal sign must be marked by a '5'.
If the mask does not contain any sign, only floating minus signs are set before the first digit. Otherwise, the '-' (only minus sign) or '+' (sign always) determines the position of the sign in the mask.

The leading digit can be marked by 0, * or > instead of by 9. With 0, leading zeros are displayed, and with *, places in front of the number are filled with * (cheque protection). With >, the preceding floating text is set in front of the first digit:

If the specified number cannot be prepared according to the pattern, the NULL value is returned by the FORMAT function.
Syntax:



