Okay so I was a character out which is why it truncated, but I would imagine there is a better way of doing this no?
function UnWrapLines(const str : String) : string;
var
lst, lst2 : TStringList;
a : Integer;
txt : String;
begin
lst := TStringList.create;
try
lst.text := str;
lst2 := TStringList.create;
try
a := 0;
if lst.count-1<>-1 then
begin
txt := lst[0];
while a<=lst.count - 1 do
begin
if a+1<=lst.count-1 then
begin
if trim(lst[a+1])<>'' then
begin
txt := txt + lst[a+1];
end else
begin
lst2.add(txt);
lst2.add('');
txt := '';
end;
end else break;
a := succ(a);
if a>lst.count-1 then break;
end;
if txt<>'' then lst2.add(txt);
end;
if trim(lst2.text)<>'' then result := lst2.text
else result := '';
finally
lst2.free;
end;
finally
lst.free;
end;
end;
As you can see, I made it a function, tidies up my actual code a little lol. But this seems somehow inelegant, and I would imagine there was a better way. Is anyone willing to help me improve this?