> Just another newbie lack-of-knowledge problem:
> What is the best way to communicate a bunch of strings through udp?
> I thought of concatenating them altogether with some symbol between (say
&),
> but how would I go about unpacking it?
procedure UnpackString(S: String; Sym: Char; StrList: TStrings);
var
s2: String;
begin
s2 := '';
while s <> '' do
begin
if s[1] = Sym then
begin
StrList.Add(s2);
s2 := '';
Delete(s, 1, 1);
end else
begin
s2 := s2 + s[1];
Delete(s, 1, 1);
end;
end;
StrList.Add(s2);
end;
S is the packed string, Sym is the separator, and StrList is a (probably
empty) TStrings instance. For example:
UnpackString('This&is&a&test', '&', Memo1.Lines);
All code 100% untested (written in OE ;), but it should work OK.
HTH,
- Matt
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz