String Functions

STRING lower(STRING);

convert to lower case

STRING upper(STRING);

convert to upper case

STRING capitalize(STRING);

capitalize first letter

STRING trim(STRING, INT);

trim to length

STRING rjustify(STRING, INT);

right justify in field

STRING save(STRING);

save and return copy of string

STRING strsave(STRING);

same as save function

STRING concat(STRING, [STRING], [...]);

catenate two strings

STRING strconcat(STRING, [STRING], [...]);

catenate two strings

INT strlen(STRING);

number of characters in string

STRING substring((STRING, INT, INT);

substring function

INT index(STRING, STRING, INT);

index function

STRING d(INT);

number as decimal string

STRING card(INT);

number in cardinal form (one, two, ...)

STRING ord(INT);

number in ordinal form (first, second, ...)

STRING alpha(INT);

convert number to Latin letter (a, b, ...)

STRING roman(INT);

number in Roman numeral form (i, ii, ...)

STRING strsoundex(STRING);

find SOUNDEX value of arbitrary string

INT strtoint(STRING);

convert numeric string to integer

INT atoi(STRING);

convert numeric string to integer

INT strcmp(STRING, STRING);

general string compare

BOOL eqstr(STRING, STRING);

compare strings for equality

BOOL nestr(STRING, STRING);

compare strings for inequality

These functions provide string handling. Many of them use an approach to memory management chosen to minimize memory use. A function using this approach constructs its output string in its own string buffer, reusing that buffer each time it is called. When a function using this approach returns a string value it returns its buffer. In consequence the strings returned by these functions must be either used or saved before the function is called again.

Lower and upper convert the letters in their arguments to lower or upper case, respectively. Capitalize converts the first character of the argument, if it is a letter, to upper case. Lower and upper use the buffer return method; capitalize operates on and returns its argument.

Trim shortens a string to the length specified by the second parameter. If the string is already of that length or shorter the string is not changed. Rjustify right justifies a string into another string of the length specified by the second parameter. If the original string is shorter than the justified string, blanks are inserted to the left of the original string; if the string is longer than the justified string, the original string is truncated on the right. Trim uses the buffer return method; rjustify creates and returns a new string.

Save creates a copy of the argument string and returns it. This function is required because built-in functions that return strings use the buffer return method; if a string is to be used repeatedly or long after it is returned from a function, it should first be saved by using the save function. Strsave is the same function as save.

Concat and strconcat catenate strings and return the result. They are identical functions. They may take two to 32 string arguments; null arguments are allowed. The arguments are catenated together into a single, newly allocated string, which is returned.

Strlen returns the length of the string argument.

Substring returns a substring of the first argument string. The second and third arguments are the indices of the first and last characters in the argument string to use to form the substring. The indexes are relative one. Substring uses the buffer return method.

Index returns the character index of the nth occurrence of a substring within a string. The index is the relative one character offset to the beginning of the substring. The first argument is the string; the second argument is the substring; and the third argument is the occurrence number.

D, card, ord, alpha and roman convert integers to strings. D converts an integer to a numeric string; card converts an integer to a cardinal number string (eg, one, two, three); ord converts an integer to an ordinal number (eg, first, second, third); alpha converts an integer to a letter (eg, a, b, c); and roman converts an integer to a Roman numeral (eg, i, ii, iii).

Strsoundex converts an arbitrary string to a SOUNDEX value. Non-ASCII text characters are ignored in the string.

Strtoint converts a numeric string to an integer. Atoi is identical to strtoint.

Strcmp compares two strings and returns an integer that is less than zero, equal to zero, or greater than zero, if, respectively, the first string is lexicographically less than, equal to, or greater than the second string. Eqstr and nestr return whether two strings are equal or not equal, respectively.