OPEN File name FOR [ READ ] [ WRITE ] [ CREATE | APPEND ] [ DIRECT ] [ WATCH ] [ BIG | LITTLE ] AS # Variable
Opens a file for reading, writing, creating or appending data.
If the DIRECT keyword is specified, the input-output are not buffered.
If the WATCH keyword is specified, the file is watched by the interpreter :
File_Read()
is called.
File_Write()
is called.
If the BIG or LITTLE keyword is specified, then all subsequent READ and WRITE operations on this file will use big-endian or little-endian data representation.
The variable receives the object that represents the opened stream.
Watching a serial port :
DIM hFile AS File OPEN "/dev/ttyS0" FOR READ WRITE WATCH AS #hFile ... PUBLIC SUB File_Read() DIM iByte AS Byte READ #hFile, iByte PRINT "Got one byte: "; iByte END
Reading data from a BMP file, known to use little-endian format :
DIM hFile AS File DIM iData AS Integer OPEN "./image.bmp" FOR READ LITTLE AS #hFile ... READ #hFile, iData