FOLDDW(), FOLDDWS()

FOLDDW(), FOLDDWS()

Top  Previous  Next

 

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

 

 

Format

 

FOLDDW(string, width {, delim})

FOLDDWS(string, width {, delim})

 

where

 

stringevaluates to the string to be formatted

 

widthevaluates to the maximum length for each fragment as a display width.

 

delimevaluates to the delimiter character to appear between each fragment.

 

 

The FOLDDW() function breaks string into sections, placing the delim character between each section. Each section has a display width not exceeding width 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 FOLDDWS() function is similar to FOLDDW() but works on each field, value or subvalue of string separately, returning a similarly structured dynamic array of folded strings

 

On a non-ECS system, the FOLDDW() and FOLDDWS() functions are identical to FOLD() and FOLDS().

 

 

Example

 

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

X = FOLDDW(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:

DISPLAY.WIDTH(), FOLD()