FID() Function - Get File Identification BBj

For this topic's original documentation, see the FID() Function - Get File Identification.

BBj-Specific Information

See the SETTERM documentation for an example of how to use this verb for applications that rely on the FID(0) and will be run in a Web browser.

In BBj, the FID() function returns the filename as reported by the operating system. In BBx, it returns the filename from the original OPEN. For example:

Assume that the actual filename reported by the operating system is MyFile.DAT.

OPEN (1)"myfile.DAT"

In BBj, a filename of "MyFile.DAT" is returned.

In BBx, a filename of "myfile.DAT" is returned.

The file name in the FID differs in VPRO/5 and BBj when a file is opened using a segment from the PREFIX. In VPRO/5, the drive letter, prefix segment, and the file name are included in the FID. In BBj, the file name in the FID includes the drive letter, the directory, prefix segment, and file name. 

For example, if the current drive is C:\ and current directory is \BBJ with a prefix including DY/, then opening a file named VM040 in the DY directory will return different results in Visual PRO5 and BBj. Visual PRO5 returns C:DY/VM040. BBj returns C:/BBJ/DY/VM040.

BBj attempts to optimize file access by not making unnecessary data server connections. This means that if a file is opened using data server syntax and does not need to actually make a connection to a separate data server, no connection is made and the file is opened locally. Therefore, the file path returned in the FID might not contain data server syntax. The path returned in the FID is the actual path used to open the file.




The FID() function returns a string describing the attributes of the file currently OPENed on channelno. If channelno was OPENed with an alias and resulted in opening a BBj device, FID() returns only the alias name.

Channel zero refers to the terminal device. Normally, the value returned by FID(0) is the terminal alias (T0, T1, etc.). However, if BBj is running in background or with redirected standard I/O, the file name associated with channel 0 will be IO, which has no special capabilities other than to read and write data.

If the channel was opened without an alias, then FID() returns a string with the following information:



Conversion Code


File Type

FID$ (1,1)



$00$ = indexed file
$01$ = serial file
$02$ = keyed file
$03$ = string file
$04$ = BBx tokenized program file
$84$ = BBj tokenized program file
$05$ = directory file
$06$ = multi-keyed file
$07$ = C-ISAM file
$08$ = XKEYED file
$09$ = FULLTEXT file (BBj 15.0 and higher)
$0B$ = JKEYED file
$0C$ = encrypted file opened without its required password*
$0D$ = VKEYED file

*Data will appear "corrupted" as proper unencryption requires a password.

The FID()file type can be modified by flags that define variations of MKEYED and XKEYED files. The flags have the following meanings:

$2x$ = 64-bit large file
$4x$ = Highly recoverable file

The following are examples of files with different flag combinations:

$06$ = 2 GB MKEYED file
$26$ = 64-bit MKEYED file
$46$ = 2 GB MKEYED file, highly recoverable
$66$ = 64-bit MKEYED file, highly recoverable

$08$ = 2 GB XKEYED file
$28$ = 64-bit XKEYED file
$48$ = 2 GB XKEYED file, highly recoverable
$68$ = 64-bit XKEYED file, highly recoverable


Logical key size or 0 for MKEYED, XKEYED, or VKEYED files.



Number of records or -1 for byte-oriented files.



Bytes per record or -1 for byte-oriented files.



File name.


The FIN() Function may also be used to provide information about an open file.


>LET A$=FID(6)
>PRINT A$(9)
>PRINT DEC(A$(7,2))

See Also

Data Server Syntax

Functions - Alphabetical Listing


Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.