hmm... i have had no trubble with that...

i use Indy 10 for sockets (just figured out how to get it to listen properly, as you can see of my previous thread), and have made my own End-Of-Line, because the original one is just two bytes, that can easily be stumbled uppon in a packet. hterefor, my EOL is now: "'|NDPKG|'+EOL". To use it when sending, just add '|NDPKG|' to whatever you are sending, and it will work.

i am happy to give you my "ConvertUtils.pas", if it can help!
besides: you all have helped me fix some major bugs in it!

Hint: Look at my "StrToRaw" and "GetStr" functions

[pascal]
unit ConvertUtils;

interface

uses
Dialogs;

type
TStrArray4 = Array[1..4] of Char;
TStrArray8 = Array[1..8] of Char;

function ToRawString(P: PChar; Length: Integer) : string;
function StrToHex (Str: String) : String;
function HexToInt(s: string): Longword;
function HexToStr(HexStr: String): String;
function InvertHex(HexStr: String): String;
function InvertStr(Str: String): String;

function StrToRaw(S: String): String;
function BoolToRaw(B: Boolean): String;
function ByteToRaw(B: Byte): String;
function IntToRaw(I: Integer): String;
function Int64ToRaw(I: Int64): String;
function SingleToRaw(S: Single): String;

function GetInt(var RawStr: String): Integer;
function GetInt64(var RawStr: String): Int64;
function GetSingle(var RawStr: String): Single;
function GetByte(var RawStr: String): Byte;
function GetBool(var RawStr: String): Boolean;
function GetStr(var RawStr: String): String;

implementation

Uses StrUtils, SysUtils;

function StrToRaw(S: String): String;
begin
if (Length(S) <255>= 4) then
begin
IntStr:= TStrArray4(RawStr);
Delete(RawStr,1,4);
PI:= PInteger(IntStr);
Result:= PI^;
end
else
ShowMessage('GetInt: Raw String Too Short!');
end;

function GetInt64(var RawStr: String): Int64;
var
IntStr: TStrArray8;
PI: PInt64;
begin
// IntStr:= TStrArray8(RawStr);
Delete(RawStr,1,;
// PI:= PInt64(IntStr);
Result:= PI^;
end;

function GetSingle(var RawStr: String): Single;
var
SingleStr: TStrArray4;
PS: PSingle;
begin
if (Length(RawStr) >= 4) then
begin
SingleStr:= TStrArray4(RawStr);
Delete(RawStr,1,4);
PS:= PSingle(SingleStr);
Result:= PS^;
end
else
ShowMessage('GetSingle: Raw String Too Short!');
end;

function GetByte(var RawStr: String): Byte;
var
PB: PByte;
ByteStr: String;
begin
if (Length(RawStr) >= 1) then
begin
//ByteStr:= LeftStr(RawStr,1);
Result:= Ord(RawStr[1]);
Delete(RawStr,1,1);
//PB:= PByte(@ByteStr);
//Result:= PB^;
end
else
ShowMessage('GetByte: Raw String Too Short!');
end;

Function GetStr(var RawStr: String): String;
var
LenByte: Byte;
IntStr: String;
begin
if (Length(RawStr) >= 1) then
begin
LenByte:= Ord(RawStr[1]);
Delete(RawStr,1,1);
if (Length(RawStr) >= LenByte) then
begin
Result:= LeftStr(RawStr,LenByte);
Delete(RawStr,1,LenByte);
end
else
ShowMessage('GetStr: Raw String Missing Data!');
end
else
ShowMessage('GetStr: Raw String Too Short!');
end;

Function GetBool(var RawStr: String): Boolean;
var
BoolByte: Byte;
begin
if (Length(RawStr) >= 1) then
begin
BoolByte:= GetByte(RawStr);
Result:= (BoolByte = 255)
end
else
ShowMessage('GetBool: Raw String Too Short!');
end;

Function InvertHex(HexStr: String): String;
var
i,j: Integer;
temp: String;
begin
i:= 0;
j:= (length(HexStr) div 2);
while i < j do
begin
temp:= temp+RightStr(HexStr,2);
HexStr:= LeftStr(HexStr,Length(HexStr)-2);
inc(i);
end;

Result:= temp;
end;

Function InvertStr(Str: String): String;
var
i,j: Integer;
temp: String;
begin
i:= 0;
j:= length(Str);
while i < j do
begin
temp:= temp+RightStr(Str,1);
Str:= LeftStr(Str,Length(Str)-1);
inc(i);
end;

Result:= temp;
end;

Function HexToStr(HexStr: String): String;
var
Buffer: Array of Byte;
i,j: Integer;
begin
i:= 0;
SetLength(Buffer, Length(HexStr) div 2);
j:= 1;
while i < Length(Buffer) do begin
Buffer[i]:= StrToInt('$'+ MidStr(HexStr,j,2));
Inc(j); Inc(j);
inc(i);
end;
Result:= ToRawString(PChar(Buffer),Length(Buffer));
end;

function HexToInt(s: string): Longword;
var
b: Byte;
c: Char;
begin
Result := 0;
s := UpperCase(s);
for b := 1 to Length(s) do
begin
Result := Result * 16;
c := s[b];
case c of
'0'..'9': Inc(Result, Ord(c) - Ord('0'));
'A'..'F': Inc(Result, Ord(c) - Ord('A') + 10);
else
raise EConvertError.Create('No Hex-Number');
end;
end;
end;

function StrToHex (Str: String) : String;
var
i, len: integer;
byte: string;

begin
len:= Length(Str);
i:= 1;

while i <len> 0) do begin
Result := result + c;
P := P + 1;
c := P^;
Length := Length - 1;
end;
end;

end.
[/pascal]