Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

OPEN

Description

This command opens files for read or write access. OPEN requires three arguments:

A string that is the access type

"R" - Open file for reading. The file must exist
"W" - Open file for writing. A new file will be created.
"WB" - Same as W but uses buffering. (new since V4.20)
"A" - Open file for appending data. The file must exist.
"AB" - Same as A but uses buffering. (new since V4.20)

A number in the range from 0...100

This is the file handle that must be used for subsequent access to the file.

The file name

This must be a FAT16 compatible string in 8.3 format.

OPEN sets LASTERR to 0 (ERR_OK) on success. Any other value indicates an error.
The buffered modes "AB" and "WB" are useful when small chunks of data must be written at a relatively high frequency. In buffered mode, the size of a single write (e.g. PUT) is restricted to 1550 bytes.

Example

The following example opens the file "test.txt" for reading and prints out the first few characters. It's a cheap UNIX "head" command.

outmode -2
open "R", 1, "test.txt"
if LASTERR = 0 then
   get 1, a$
   print a$
   close 1
else
   print "could not open!"
end if

Remarks

OPEN only works on modules that have some kind of mass storage such as an USB Stick or SD Card.