Show: Object Pascal C++
Display Preferences


From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function WrapText(const Line, BreakStr: string; const BreakChars: TSysCharSet; MaxCol: Integer): string;
function WrapText(const Line: string; MaxCol: Integer): string;


extern DELPHI_PACKAGE System::UnicodeString __fastcall WrapText(const System::UnicodeString Line, const System::UnicodeString BreakStr, const TSysCharSet &BreakChars, int MaxCol)/* overload */;


Type Visibility Source Unit Parent
function public
System.SysUtils System.SysUtils


Inserts a line break into a string as its length approaches a specified size.

Commonly, the WrapText routine searches for space, hyphen, or tab characters where to break the line and inserts a carriage return/line feed pair on Windows, or a linefeed on MacOS, before counting MaxCol characters (first overload).

The second overload will insert a new string sequence (specified by the BreakStr parameter) at the last occurrence of any of the break characters specified in the BreakChars set parameter, before counting MaxCol characters.

For instance, after running the following code

WrapText('The rain in Spain falls mainly on the plain.', #13#10, ['.',' ',#9,'-'], 15);
TSysCharSet bChars;
bChars << '.' << ' ' << '/t' << '-';
WrapText("The rain in Spain falls mainly on the plain.", "/n", bChars, 15);

the result will be:

The rain in Spain
falls mainly on the

See Also

Personal tools