which requires a start position and a length. These two numbers have to be passed as decimal values. This is a problem as the start position and length are stored in hexadecimal which means that the hex values read from the files have to be converted to decimal before the data can be located and read.read from file
To conduct the conversion I have the following function:
Code: Select all
Private function HexToDecimal pBytes,pIsLittleEndian
/* pBytes is a comma seperated list of bytes read from file
*/
## Each loop starts with the units, followed by squared, followed by pwr 4, pwr 6 ...
put the number of items in pBytes into tByteCount
put 0 into tPwr
Switch pIsLittleEndian
Case true
Repeat for each item tByte in pBytes
put tByte into tInt
add tInt*(16^tPwr) to tValue
add 2 to tPwr
end Repeat
break
Case false
Repeat with N = tByteCount down to 1
put (item N of pBytes) into tInt
add tInt*(16^tPwr) to tValue
add 2 to tPwr
end Repeat
break
end Switch
return tValue
end HexToDecimal
livecode pulls a trick and saves the number as0x1332F47 = decimal 20131655
which is not accurate enough.2.01317e+07
I wonder if there is a way of stopping livecode from storing the number in scientific notation.