FOLD() and FOLDS()

FOLD(), FOLDS()

Top  Previous  Next

 

The FOLD() function breaks a string into field mark delimited sections no longer than a given width, placing breaks on spaces where possible.

 

 

Format

 

FOLD(string, width {, delim})

FOLDS(string, width {, delim})

 

where

 

stringevaluates to the string to be formatted

 

widthevaluates to the maximum length for each fragment.

 

delimevaluates to the delimiter character to appear between each fragment.

 

 

The FOLD() function breaks string into sections, placing the delim character between each section. Each section is at most width characters in length with the break from one section to the next occurring at a space where possible.

 

The width argument may be multivalued. In this case, the first value specifies the width for the first fragment of the result, the second value specifies the width for the second fragment of the result and so on. If there are more fragments in the result than there are width specifications, the final width is used for the remaining data.

 

The delim argument is optional. If omitted, a field mark is used by default. Specifying delim as a null string uses a value mark as the delimiter.

 

 

The FOLDS() function is similar to FOLD() but works on each field, value or subvalue of string separately, returning a similarly structured dynamic array of folded strings

 

 

Example

 

S = 'The quick brown fox jumps over the lazy dog'

X = FOLD(S, 10)

LOOP

  CRT REMOVE(X, CODE)

WHILE CODE

REPEAT

 

The above program fragment prints

 

The quick

brown fox

jumps over

the lazy

dog

 

 

See also:

FOLDDW()