FileAttr Function

Purpose

Returns a Long representing the GFA-BASIC 32 file mode settings for files opened using the Open statement.

Syntax

FileAttr(#file, attr)

file: integer expression (0..511)
attr:iexp

Description

FileAttr returns the I/O settings of the files created or opened with the GFA-BASIC 32 command Open.

attr indicates the type of information to return.

FileAttr(#, 1) file mode:
1 = Input
2 = Output
4 = Random
8 = Append
32 = Binary
FileAttr(#, 2) the file handle (if necessary for System calls), same as _File(#)
FileAttr(#, 3) the size of the GFA-BASIC 32 file buffer (set with Len = n)
FileAttr(#, 4) Based 1 or Based 0 (set with Option Base , 0 | 1)
FileAttr(#, 5) non-zero (-1): the file is not seekable; you cannot use: Seek, RelSeek, Record, Lof, EOF etc. (LPT:, CON:).
FileAttr(#, 6) record size, random files = size of buffer, otherwise 1

Example

Open App.Path & "\Test.Dat" for Output As # 1

Print FileAttr( # 1, 1)      // Prints 2

Close # 1

Kill App.Path & "\Test.Dat" // Tidy-up line

Remarks

GFA-BASIC 32 manages a file record for each opened file. FileAttr allows retrieving the record fields.

GetAttr and SetAttr retrieve and set the file type attributes at the system level.

See Also

_File(), FileLen(), GetAttr, SetAttr

{Created by Sjouke Hamstra; Last updated: 05/10/2014 by James Gaite}