Registriert seit: 14. Apr 2004
Ort: Karlsruhe
318 Beiträge
Delphi 2010 Architect
|
AW: Ich scheitere grade an simpler Mathematik
28. Mär 2017, 19:22
Immer schön, wenn dann nicht die Lösung genannt wird.
Da freut sich jeder mit dem gleichen oder einem änlichen Problem, wenn er irgendwann diesen Thread findet.
Delphi-Quellcode:
Const
MAX_LENGTH = 248;
Var
result[]: String;
lines[]: String = Split(Value, #13#10);
line: String;
count, pos, rest: Integer;
levelStart, levelContinued, levelConcatenate: String;
Begin
levelStart = IfThen(reference <> "", Join(Array(startLevel, reference, startTag), SPACE), Join(Array(startLevel, startTag), " "));
levelContinued = Join(Array(Integer(startLevel + 1).ToString, "CONT "), " ");
levelConcatenate = Join(Array(Integer(startLevel + 1).ToString, "CONC "), " ");
For i As Integer = 0 To lines.Count Do
pos = 0;
line= lines[I];
rest = Lenght(line);
count = Min(MAX_LENGTH, Length(line));
result.Add(Join(Array(IfThen(i = 0, levelStart, levelContinued), Copy(line, pos, count)), " "));
rest = rest - count;
While rest > 0 Do Begin
pos = pos + count;
count = Min(MAX_LENGTH, rest);
result.Add(Join(Array(levelConcatenate, Copy(line, pos, count)), " "));
rest = rest - count;
End;
End;
Return Join(result, #13#10);
End;
|
|
Zitat
|