Skip to content

FID

File Identification

This string function returns the file identification data for a file or device that is OPEN on the specified channel.

FID (channel [,ERR=line-ref|,ERC=error-code])
channel
is an integer in the range of 0 to 32764 specifying the channel of an OPEN file or device.
line-ref
is the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

For files, a 22-byte string is returned in the following format:

Byte(s)
Description
1 - 3
If this is a Btrieve file, byte 1 is equal to "B".

On VMS, if this is an RMS file, 1 is equal to “R” and byte 2 is equal to the sector number used to create the file. The sector number is stored in binary form, e.g. BIN(sector-number, 1).

If this file is Encrypted, bytes 1 – 3 will contain “ENC”.

In all other cases these bytes are unused ($000000$)

4 - 9
File name, first 6 characters
10
File type:

$00$-INDEXED file
$01$-SERIAL file
$02$-DIRECT or SORT file
$03$-TEXT file
$04$-Program file
$06$-MSORT file
$07$-TISAM & compatible
$0A$-Logical Disk Directory
$0B$-System file

11
Binary sum of Key Size Pointer Size:

SERIAL, INDEXED, and Program files: $00$;

SORT or DIRECT files: key size + 4 for fewer than 32,768 records; key size + 6 for more than 32,767 records: For autoexpanding files, this value is always key size + 4 because the number of records defined for autoexpanding files is 0 (zero).

12 - 14
Binary number of records in file; Program and System files=$000001$
15 - 16
Binary number of bytes per Record:

Sort=$0000$;
Program=always a multiple of 256

17 - 19
Binary number of 256-byte sectors
20
Binary Logical Disk Directory number
21 - 22
File name, last 2 characters
23 +
See bytes 23+ for logical disk directories

For logical disk directories, a 22- or 46-byte string is returned in the following format:

Byte(s) Description
1 - 10 Same as files
11 Unused ($00$)
12 - 14 Same as files
15 - 16 Binary number of bytes per Record
17 - 19 Unused ($000000$)
20 - 22 Same as files
23 + Additional bytes of directory path name, if needed

For tasks and devices, a 2-byte string is returned in the following format:

Byte(s)
Description
1 - 2
Task or device name

The result may contain unprintable ASCII characters, which can be converted to printable form by using the HTA or DEC functions.

LET X$=FID (1)
PRINT X$ (4,6)

If this prints “IND456”, then “IND456” is the file that is OPEN on channel 1.

PRINT DEC (X$(10,1))

shows the file type code. If the file type code is 4, the file is a program file.

SEE ALSO

FILE and INITFILE directives
DSD, FST, and XFD functions

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF