The last one won't work because for some reason the array isn't being past around correctly...
I did a local test with this one.
I am assuming because its a network thing that #10 will be the predominate line ending here but it will check for CR in case it gets in there.
Basically because if only a #13 is received then you can switch it around.. I suppose you could do a test to determine which order is being use..
This version requires that you maintain two items somewhere between calls.
var
Form1: TForm1;
MyBufferList:TstringList; //Create this at start somewhere., keep it alive
WorkString :String;
implementation
{$R *.lfm}
{ TForm1 }
Function StrFromMyBuf(TheBuf:Pchar;Count:Integer):TStringList;
var
E:Pchar;
L:Integer;
LE:Char;
Begin
E := TheBuf; Inc(E,Count); //Mark the buffer end;
L:= 0;
While TheBuf < E DO
Begin
if TheBUf^ <> #10 Then WorkString := WorkString+TheBuf^ Else
Begin
While Pos(#13, WorkString)<>0 DO Delete(WorkString, Pos(#13,WorkString),1);
MyBufferList.Add(WorkString);
WorkString := '';
end;
Inc(TheBuf);
end;
end;
Cast your buffer to a PChar(@MyBuffer), Count etc..