-
(OT) Delphi / Pascal
Could someone tell me why this doesn't work? I have yet to find a decent Pascal / Delphi Forum....
Code:
function MakePacket(ID: string; Data: string):string;
var s1:string; i1:integer;
begin
i1 := length(Data) + 4; // length of packet
s1 := StringOfChar(' ',2); //initialize string * 2
CopyMemory(@s1,@i1,2); //convert length to string
MakePacket := (ID) + s1 + Data; //make packet.
end;
-
What is the output and are you using /0 terminated strings or Pascal style?
Why add 4 to the length (byte?)
Cheers,
P.
-
The error occurs at the CopyMemory -- at this point the program will lock up until it runs out of memory. The output should look like this: ID (two bytes) + Legth (two bytes) + Data (x bytes)
This is why I add 4 to the Length.