fold() Function

The fold() function folds a string expression into a string of a given length.

Syntax

fold(str.exp, fold.length.exp, delimiter)

Parameter(s)

str.exp  

String to be folded.

fold.length.exp  

Length to which the string expression is folded. If omitted, it defaults to 25. Multiple numeric expressions, separated by value marks, can be specified in this parameter.

delimiter

Delimiter used in the folded text.

Description

The text is folded (or wrapped) so the length of the first line is less than or equal to the value of the first numeric value in the fold.length.exp, the length of the second line is less than or equal to the value of the second numeric value in the fold.length.exp, and so on. If more strings exist than the corresponding number of fold length expressions, the last fold length expression is applied to the remaining strings. If possible, the text is folded on a space.

The delimiter parameter is required by the compiler, but the parameter can be null, in which case a value mark (char(253)) is used. Only the first character of a provided delimiter is used.

Example(s)

equ svm to char(252)

input string

string=fold(string,10,svm)

print string

When the string:

this is a test string to demonstrate "fold"

is entered, the string is embedded with the requested subvalue marks as follows:

this is a\test\string to\demonstrat\e "fold"

a = fold(a,25,"")

or

delimiter = ""

a = fold(a,25,delimiter)

In the first example a sub-value was specified and used, but in the second example a value mark is used by default as the fold delimiter.

See Also

count() Function

BASIC Functions

occurs() Function

Statements and Functions