Armand, Bingo. Thanks for that. I had presumed that there must be some way of addressing the array directly into some form of string representation (PChar, AnsiChar etc). I will test this code this evening.
Thanks to Armand and all who replied. Kind regards, Darren -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Armand Postma Sent: 24 April 2005 19:37 To: Borland's Delphi Discussion List Subject: Re: Array of byte to string conversion Hello Darren, As far as I know there is no direct conversion, but you can convert an array of bytes to a PChar quite easily and you can simply assign a PChar to a String variable without any problems like this: a1: array[1..13] of Byte = ($68,$74,$74,$2E,$76,$65,$72,$69,$6E,$74,$6F,$2E,$63); a2: array[1..13] of Byte = ($6F,$6D,$2F,$73,$74,$6F,$6D,$65,$72,$2E,$61,$73,$70); var Test : String; Test := Pchar(@a1); However that will probably generate some extra characters since there is no end marker! :) A PChar uses a #0 to mark the end of the string, so to solve that problem simply add a 0 at the end of the array of bytes: a1: array[1..14] of Byte = ($68,$74,$74,$2E,$76,$65,$72,$69,$6E,$74,$6F,$2E,$63, 0); Test := PChar(@a1); will now generate the string you want! :) Hope this helps. Yours, Armand Postma Darren McBride wrote: > Folks, > > How do I convert the following array to a string ? Does anyone have a > Hex conversion routine or a link they can point me to ? > > a1: array[1..13] of Byte = > ($68,$74,$74,$2E,$76,$65,$72,$69,$6E,$74,$6F,$2E,$63); > a2: array[1..13] of Byte = > ($6F,$6D,$2F,$73,$74,$6F,$6D,$65,$72,$2E,$61,$73,$70); > > Do I have to convert the hex to decimal and then use the Ord function, > or is there a single function that will do the job ? > > I am using Delphi 6. > > Many thanks, > Darren > > _______________________________________________ > Delphi mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi -- Visit the Lion Productions website at: http://lionprod.f2o.org _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

