[Overview][Constants][Types][Procedures and functions][Index] Reference for unit 'LazStringUtils' (#lazutils)

BreakString

Applies line breaks and indenting to a string value.

Declaration

Source position: lazstringutils.pas line 66

function BreakString(

  const s: string;

  MaxLineLength: Integer;

  Indent: Integer

):string;

Arguments

s

  

Contains the text examined and formatted in the routine.

MaxLineLength

  

Maximum length of lines in the converted value.

Indent

  

Number of Space characters prepended as an indent for lines in the converted value.

Function result

String with values after applying line breaks and indent spacing.

Description

BreakString is a String function used to apply line breaks and indent spacing to the text specified in S.

MaxLineLength contains the maximum number of characters allowed on any given line.

Indent contains the number of space characters used to indent text following a line break. The value in Indent may be adjusted if it is too large for the value specified in MaxLineLength.

BreakString examines values in S and counts the number of characters in each of the lines. Existing CR (#13) or LF (#10) characters are preserved. If the value in MaxLineLength is reached for any given line, a new line is created by inserting the value in LineEnding. The line break occurs at a natural word boundary when one can be determined.

Inserting a line break causes an indent with the number of space characters in Indent to be inserted in the return value following the line break.

The process is repeated until all values in S have been handled.

The return value contains the content in S after applying line breaks and indent spacing.

See also

LineEnding


Version 4.0 Generated 2025-05-03 Home