Places attribute marks in a string in place of spaces, so as to break the string into lines with a specified maximum length.
FOLD(string, fold-width)
string The text to fold.
fold-width The maximum number of characters in each fold.
A dynamic array containing the processed text.
The FOLD function counts the characters in the string and replaces the last space before the position specified by fold-width with an attribute mark. If there are no spaces before the specified position, an attribute mark is inserted after the character in the position specified by fold-width. The character following the attribute mark is then taken as the start of a new string and the process repeats until the end of the string.
This function provides the same functionality as 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.