program WrapTextProject;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.StrUtils;
const
cText = '
The rain in Spain falls mainly on the plain.';
var
MyWrapedText, MyWrapedWithEllipsisText:
string;
I, SplitPoints: Integer;
begin
try
Writeln('
Org: ' + sLineBreak, cText, sLineBreak);
MyWrapedText := WrapText(cText, sLineBreak, ['
'], 15);
Writeln('
Wraped: ' + sLineBreak, MyWrapedText, sLineBreak);
MyWrapedWithEllipsisText := '
';
SplitPoints := 0;
for I := 1
to Length(MyWrapedText)
do
begin
if IsDelimiter(sLineBreak, MyWrapedText, I)
then
begin
Inc(SplitPoints);
if SplitPoints > 2
then
begin
MyWrapedWithEllipsisText := MyWrapedText;
SetLength(MyWrapedWithEllipsisText, I + 1);
MyWrapedWithEllipsisText := MyWrapedWithEllipsisText + '
...';
Break;
end;
end;
end;
Writeln('
Wraped with Ellipsis: ' + sLineBreak, MyWrapedWithEllipsisText, sLineBreak);
Readln;
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
end.