APPEXENAME$
function
APPEXEPATH$ function
BCXPATH$ function
BFF$ function
CLOSE statement
COMBOBOXLOADFILE statement
COPYFILE statement
EOF
statement
EXIST function
FILELOCKED function
FINDFIRST$ function
FINDNEXT$ function
FREEFILE function
GETFILENAME$ function
GETATTR statement
KILL statement
LISTBOXLOADFILE statement
LOADFILE$ function
LOC function
LOF
function
LOOKAHEAD$ function
OPEN statement
PELLESPATH$ function
REC function
RECCOUNT function
RECORD function
RECLEN statement
RENAME statement
REWIND statement
SETATTR statement
FILELOCKED determines whether or not a file can be opened.
Syntax:RetVal = FILELOCKED(FileName AS STRING) Parameters: |
The $FILETEST ON or $FILETEST OFF directives specify whether or not to suppress the automatic failure checking when using OPEN and CLOSE statements.
👉 In the C translation of OPEN and CLOSE statements, BCX automatically adds code to check for the existence of the file that is being opened or closed. If the file being opened does not exist, the program will exit and a "Can't open file FileName$" statement will be sent to stdout.
Syntax:$FILETEST ON or $FILETEST OFF Parameters: |
The OPEN statement opens a file, specifies a streaming mode, and associates a file handle name with the file.
Every OPEN statement must be terminated, eventually, with a CLOSE statement. See the CLOSE section below for details.
Syntax:OPEN FileName FOR StreamingMode AS hFile Parameters:
|
👉 In the C translation of OPEN and CLOSE statements, BCX automatically adds code to check for the existence of the file that is being opened or closed. If the file being opened does not exist, the program will exit and a "Can't open file FileName$" statement will be sent to stdout.
The CLOSE statement causes the file stream associated with a file handle to be flushed and the file to be closed.
Syntax 1:CLOSE hFile Parameters:
|
Syntax 2:CLOSE Parameters:
|
👉 The CLOSE statement allows multiple file handles on one line. For example,
CLOSE #1, #2, FP3, MyDocHandle
Streaming Mode: open text file for reading.
Syntax:OPEN FileName FOR INPUT AS hFile Parameters:
|
Streaming Mode: truncate contents of existing file to zero length or create text file for writing.
Syntax:OPEN FileName FOR OUTPUT AS hFile Parameters:
|
Streaming Mode: truncate contents of existing file to zero length or create text file for writing.
Syntax:OPEN FileName FOR APPEND AS hFile Streaming Mode: append; open or create text file for writing at end-of-file. Parameters:
|
Streaming Mode: open binary file for update (reading and writing).
Syntax:OPEN FileName FOR BINARY AS hFile Parameters:
|
Streaming Mode: truncate contents of existing file to zero length or create binary file for update.
Syntax:OPEN FileName FOR BINARY NEW AS hFile Parameters:
|
Streaming Mode: append; open or create binary file for update, writing at end-of-file.
Syntax:OPEN FileName FOR BINARY APPEND AS hFile Parameters:
|
Streaming Mode: open binary file for reading.
Syntax:OPEN FileName FOR BINARY INPUT AS hFile Parameters:
|
Streaming Mode: open binary file for update (reading and writing).
Syntax:OPEN FileName FOR BINARY OUTPUT AS hFile Parameters:
|
Expressions such as:
OPEN EXTRACT$(FileName,".") & ".bas" FOR INPUT AS FP1
are valid.
DIM MyFileHandle@ ' BCX Reserves @ for C FILE* data types OPEN "new.txt" FOR OUTPUT AS FP1 MyFileHandle@ = FP1 FPRINT MyFileHandle@, "This is a test" CLOSE FP1or, for example, like this
GLOBAL DYNAMIC FHandles[12] AS FILE PTR LOCAL DYNAMIC FHandles[12] AS FILE PTR
OPEN "new.txt" FOR INPUT AS FP1 PARSE$(FP1) CLOSE FP1 FUNCTION PARSE$ (ABC AS FILE) LOCAL Buffer$ LINE INPUT ABC, Buffer$ PRINT Buffer$ FUNCTION = Buffer$ END FUNCTION
In the snippet below, the file handle name MyFP1 will be LOCAL in scope to the subroutine FileTest.
SUB FileTest () DIM RAW MyFP1 AS FILE OPEN "test.txt" FOR BINARY AS MyFP1 CLOSE MyFP1 END SUB
OPEN "Junk.txt" FOR OUTPUT AS FP1 PRINT FilenameFromFileNumber$(FP1) ' Should display Your_Drive:\Your_Path\Junk.txt CLOSE FP1 KILL "Junk.txt" FUNCTION FilenameFromFileNumber$ (FP AS FILE) ' This might cause problems on networked files. DIM Tmp$ * 2048 IF GetFinalPathNameByHandle((HANDLE)_get_osfhandle(_fileno(FP)), Tmp$, 2048, 0) THEN strcpy(Tmp, Tmp+4) FUNCTION = Tmp$ END FUNCTION