OPENFILE

Top  Previous  Next

Syntax

INT = OPENFILE(fptr as FILE | BFILE, filename as STRING,mode as STRING)

Description

Opens a file or stream for reading, writing or appending.

Parameters

fptr - A FILE or BFILE variable.

filename - Name of file to open, or name of a shared resource such as "LPT1:".

mode - "W" for writing, "A" for appending, "R" for reading, "R+" for read/write access on existing files.

Return value

Returns 0 on success, 1 on failure.

Remarks

Use a BFILE variable to open the file in binary mode. Use LEN on an open file variable to determine the size of the file.

See Also: CLOSEFILE, READ, WRITE, GET, PUT

Example usage

DEF myfile as BFILE
IF OPENFILE(myfile, "C:\\temp\\temp.txt", "W") = 0
    WRITE myfile, 0xFFFF
    CLOSEFILE myfile
ENDIF