rodent59 Newbie
 Joined: 02/03/2012 Location: AustraliaPosts: 7 |
| Posted: 12:23pm 06 Mar 2012 |
|
|
|
This may well be generally known, but just in case it's not...
For MMBasic3.1
While all INPUT and PRINT commands deal with ASCII (7-bit) characters, they can handle 'whole' 8-bit bytes as follows:
Open any non-text file (say a .pdf or .jpg for example) and read a single byte:
a$=input$(1,#1)
print ASC(a$) 'returns the 8 bit result (0 to 255) or
print HEX$(ASC(a$)) 'returns the hex code for the byte.
When writing to a file:
print #2,CHR$(250); 'will write a single byte to file with decimal code 250 or
print #2,CHR$(&HE8); 'will write a single byte to file with hex code E8.
Might be useful if reading/writing non-text files sequentially.
Apologies if this is old news!
|