Search code examples
file-iobasic

Creating file with QB64


With the following

DIM a AS INTEGER
a = 10
OPEN "myFile" FOR BINARY AS #1
PUT #1, 1, a
CLOSE #1

I get a file (myFile) with two bytes (using QB64). The first byte is indeed 0A, but there is a second byte 00.

How can I create a file with just one byte?


Solution

  • Try this

    DIM a AS _UNSIGNED _BYTE
    a = 10
    OPEN "myFile" FOR BINARY AS #1
    PUT #1, 1, a
    CLOSE #1
    

    It seems like INTEGER is 2 bytes.