Cicode Programming Reference > Cicode Function Categories > String Functions > StrToLines

StrToLines

Converts a string into separate lines that contain no more than the number of characters specified in the MaxChars argument.

The function splits the string by inserting newline characters into the text string, thus dividing it into separate lines. The string will be split at a whitespace character if possible, and that whitespace will be replaced by the newline character. If no whitespace characters are available then the insertion will be made at the maximum number of characters from the previous line break.

Syntax

StrToLines(String,MaxChars, nLines)

String:

The string to convert.

MaxChars:

The maximum number of characters permitted in each new line produced by the StrToLines() function.

nLines:

Output Parameter: Returns the number of lines produced by the StrToLines() function from the input string. This should be a Cicode INT type variable.

Return Value

A string containing the input string with new line characters inserted into it.

Example

BrokenString=StrToLines("Was that a real Stegosaur?", 5, nLines);
!The function returns the value 6 in nLines, and Broken String now contains:
Was
that
a
real
Stego
saur?
BrokenString=StrToLines("It breaks the string by inserting newline characters into the text.", 16, nLines);
!The function returns the value 6 in nLines, and Broken String now contains:
It breaks the
string by
inserting
newline
characters into
the text.

See Also

String Functions, Using the Caret Escape Sequence Character

Published June 2018