Places delimiters in a string in place of spaces, so as to break the string into lines with a specified maximum length.
FOLD(string{, foldWidth{, delimiter})
string The text to fold.
foldWidth Optional. The maximum number of characters in each fold. If omitted, defaults to 25.
If a dynamic array of integers is specified, the values of the elements are used in order as fold widths, with the last value being used for any folds that remain. Note that if an element that does not evaluate to an integer is encountered, a null string is returned.
Note that array elements are only used if the delimiter parameter is included. If foldWidth is an array, but no delimiter is specified, the first element in the array is used for all folds.
delimiter Optional. A string that specifies the delimiter to be inserted into the folded string:
A string containing the processed text.
The FOLD function counts the characters in the string and replaces the last space before the position specified by foldWidth with the specified delimiter. If there are no spaces before the specified position, a delimiter is inserted after the character in the position specified by foldWidth. The character following the delimiter is then taken as the start of a new string and the process repeats until the end of the string.
This function provides similar functionality to the T alignment code in a data definition item.
The following program breaks a line of text into attributes, and displays them on the screen:
LINE = "" FOR I = 1 TO 4 LINE := "The quick brown fox jumps over the lazy dog. " NEXT I LINE := "Thequickbrownfoxjumpsoverthelazydog." LINES = FOLD(LINE, 23) FOR I = 1 TO DCOUNT(LINES, @AM) PRINT LINES<I> NEXT I
The output from this program:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. Thequickbrownfoxjumpsov erthelazydog.