Results 1 to 3 of 3

Thread: (OT) Delphi / Pascal

  1. #1

    Thread Starter
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    (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;
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    What is the output and are you using /0 terminated strings or Pascal style?

    Why add 4 to the length (byte?)

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3

    Thread Starter
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    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.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width