Hi Actually, I dont think this quite what I want, Unless Im Misunderstanding whats going on. If I have a number 78487500, this traslates to CC 9F AD 04. If I carry out your method, I get 8 bytes added to the initial string. However,If I read the hex number from a file on disc, it only takes up 4 bytes So CC is 1 byte, 9F is one byte, and so on This what I want To be able to add the Hex string to an existing string, so when I look at it on disc it only takes up 4 bytes To see this in action, look at the first 12 Bytes of any wav header Bytes 1-4 hold the Hex version of the Letters RIFF the next 4 Bytes hold the Hex version of the total length of the file-8 bytes Bytes 9-12 hold the Hex Version of the Letters WAVE and so on. What I want is, knowing the Total Length of the File in Hex, How do I arrange the string I;m going to write to file, so the Length is comtained in 4 bytes, Including padding bytes if necessary Sorry, long winded explanation thanks -pm
On Thu, Feb 21, 2019 at 11:22 PM Peter Mew <[email protected]> wrote: > Hi > Yes, Thats it almost exactly, I just need to convert to little endian, I > think I can manage that! > Thanks > -pm > > On Thu, Feb 21, 2019 at 10:45 PM Arnaud de Montard via 4D_Tech < > [email protected]> wrote: > >> >> > Le 21 févr. 2019 à 22:09, Peter Mew via 4D_Tech <[email protected]> >> a écrit : >> > >> > Hi >> > This is driving me mad, so I hope someone will point me in the right >> > direction. >> > I have a string of text. >> > I can find its length in Hex. now I want to write this length as 4 hex >> > bytes, into the string, with the aim of doing a text to blob, later on. >> > If I just add the Hex Number to the string it takes 8 bytes >> > (String+HexByte0+HexByte1+HexByte2+HexByte3) >> > If I convert the Hex Numbers to decimal and Do >> > String+char(DecByte0)+char(DecByte1) etc. >> > It takes up 4 Bytes but the Numbers written to the string are wrong. >> >> Something like that? >> >> $hello:="hello world!" >> $len:=Length($hello) >> $hex:=String($len;"&x") >> $hex:=Substring($hex;3) >> $string:=$hex+$hello+"xxxxxxxxx" >> C_BLOB($blb) >> $charset:="utf-8" >> CONVERT FROM TEXT($string;$charset;$blb) >> $string2:=Convert to text($blb;$charset) >> $offset:=4 >> $hex2:=Substring($string2;1;$offset) >> $len2:=hexaToDecimal ($hex2) >> $hello2:=Substring($string2;$offset+1;$len2) >> ASSERT($len2=$len) >> ASSERT($hex2=$hex) >> ASSERT($hello2=$hello) >> >> -- >> Arnaud de Montard >> >> >> >> ********************************************************************** >> 4D Internet Users Group (4D iNUG) >> Archive: http://lists.4d.com/archives.html >> Options: https://lists.4d.com/mailman/options/4d_tech >> Unsub: mailto:[email protected] >> ********************************************************************** > > ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

