Thanks for your comments. Yes I am reading the data as binary.
put URL ("binfile:" & pFilePath) into tData
Working with tData requires some care as when it or any extracts from it are displayed in the IDE then any ASCII null characters are ignored when the variable contents are displayed and all other bytes are displayed as characters which should not be relied on.

this expands to:
showing the high byte values were previously ignored however the nulls are still not indicated so its best checked by copying into BBEdit or hex editor :


Reading a number of bytes from tData is achieved by using this lines similar to this :
if char tPos of tData is not numToByte(255) then exit repeat -- lost sync, bail
“char” and “byte” appear to be synonyms are read 8 bits. NumtoByte(n) is used to ensure the correct byte is searched for.
A second method is to read the file bytes in as a list of decimal numbers with a command like this :
Case "uInt1"
read from file pfileName at (pStartByte+tOffset) for pByteCount uInt1
/* Bytes are decoded to decimal and placed in varaible as comma sep data */
from
Open File pfileName for binary read
Switch pReadType
Case "uInt1"
read from file pfileName at (pStartByte+tOffset) for pByteCount uInt1
/* Bytes are decoded to decimal and placed in varaible as comma sep data */
break
Case "ASCII"
read from file pfileName at (pStartByte+tOffset) for pByteCount
break
case "Bytes"
--open file pfileName for binary read
read from file pfileName at (pStartByte+tOffset) for pByteCount
--close file pfileName
break
end Switch
Close File pfileName
Reading the first 16 bytes of the same file yields a list of bytes that is displayed in a logical fashion in the IDE and is simple to understand and work with. Parsing a list of items may be slower than reading bytes directly but I don’t have any figures yet.
tData first 16 bytes displayed in the IDE :

For those who want to know bytes 1-2 indicate that the file is a jpeg file, bytes 3-4 is an App1 marker which indicates metadata, 5-6 is the length of the block, 7 onwards indicate that the block contains Exif data which will be written to comply with the Tiff specification. Bytes 15 and 16 are an ID which is always 00 42 which I take to be a reference to “The Hitch Hikers Guide”, the following bytes are a Tiff IFD.
One advantage of reading bytes as a list is that it is relatively simple to read multi byte ID numbers and pointer values which may be encoded as LSB or MSB depending on camera manufacturer. Jpegs are read MSB except inside EXIF blocks where the data may be LSB (bytes 13 and 14 are the indicator) MM (77,77) indicates the IFD in the sample file is MSB encoded.
I pass a list of bytes to this handler to extract numerical values
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 byteToNum(tByte) into tInt
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 byteToNum(item N of pBytes) into tInt
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
Having spent some time playing with file bytes I think an option to display the contents of variables as decimal byte values in the IDE would be useful. Certainly being able to see null bytes in data would have saved me some head scratching.
S