Skip to content

XFD

Extended File Identification

This string function returns selective information on a file or device, opened on the specified channel, based on the option identifier. This information is designed to be an extension of that already available using the FID function.

XFD (channel, option [,ERR=line-ref|,ERC=error-code])
channel
is an integer value in the range of 0 to 32764 specifying the channel of an OPEN file or device.
option
is an integer value designating the source and format of the data to be returned as follows:

0 = general data for a file or directory

1 = general data for a device

2 = control and function key definitions for a channel opened to a Terminal

3 = key definition data for MSORT and TISAM files

4 = returns Link information for a file opened with OPT=LINK/DLINK

5 = general data about the file to be used with a FILE or INITFILE directive

6 = alternate-format FID data

10 = the number of records in use

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.

This function is generally available starting with release level 8.1. Option values of 0, 3, 5, 6 and 10 are generally available starting with release level 8.1; 1 starting with release level 8.2; 4 starting with release level 8.6.0; 2 starting with release level 8.7.1.

The data for option 0 is returned in the following format:

Byte(s) Description
1 - 2 Unused
3 - 10 Host File node number from UNIX
11 - 35 Unused
36 - 37 UNIX File Protection Modes
38 - 41 File size in bytes; binary
42 - 47 Unused
48 File is opened for read-only (Y/N)
49 File is opened with OPT=REVERSED (R)
50 - 53 Unused
54 - 59 File status change date/time; SQL format
60 - 65 Last access date/time; SQL format
66 - 71 Last modified date/time; SQL format
72 - 77 Size in bytes of large files.
78 - 85 Unused
86 + Reserved for full file or directory specifications

The data for option 1 is returned in the following format:

Byte(s)
Description
1
Device Type Code; binary:

0 = Unknown
1 = Disk
4 = Printer or spool file
7 = Terminal
8 = Ghost task

2 - 3
Thoroughbred Basic name of device
4 - 5
Current cursor row number, 0-based, binary; terminals and printers only
6 - 7
Current cursor column number, 0-based, binary; terminals and printers only
8 - 9
Maximum screen/line width, binary; terminals and printers only
10 - 11
Maximum screen/page height, binary; terminals and printers only
12
Spooler type, binary; printers only:

0 = Direct, no spooling
1 = Spooled, piped output
2 = Slave printer
3 = Spooled, /tmp file output

13
Lockout flag, binary; printers only:

0 = Locked out
1 = Not locked out

14 - 15
Timeout value in seconds, binary; printers only
16 - 17
Usable screen width, binary; Windows CE only
18 - 19
Usable screen height, binary; Windows CE only
20
Client/Server file system type, binary; data server devices only:

1 = ORACLE
2 = Thoroughbred
3 = ODBC
4 = MS SQL Server
5 = My SQL

21
Client/Server Case sensitivity flag, binary; SQL data server devices only:

0 = Perform a case sensitive key comparison
1 = Perform a case insensitive key comparison

22 – 43
Unused
44+
Non-printers: Host name of device Printers: UNIX command specifying where to send output

The data for option 2 is returned as a string of definition entries in the following format:

Byte(s)
Description
1
Entry length in binary; minimum 4

2 – 3 Signed binary CTL value

4+ Character(s) received from the keyboard that will produce the CTL value

The data for option 3 is returned in the following format:

Byte(s)
Description
1
File System Type code, in binary, as follows:

0 = Unknown
2 = RMS
3 = COBOL
4 = NOVELL Btrieve
5 = AS400

2
Extended File Type code, in hexadecimal, as follows:

$00$ = INDEXED
$01$ = SERIAL
$02$ = DIRECT or SORT
$03$ = TEXT
$04$ = PROGRAM
$06$ = MSORT
$07$ = TISAM and compatible files
$0A$ = Directory
$80$ = Foreign Relative Record file
$81$ = Foreign Sequential file
$82$ = Foreign Single-Keyed file
$83$ = Foreign Multi-Keyed file
$8F$ = Undefined System file

3
Number of defined sorts, unsigned binary
4
Current sort number, unsigned binary
5 - 12
Key Flags, contain Y or N:

byte 5 = Keys are prefixed to data record, default N byte 6 = “IND=” access available, default N byte 7 = File supports read-previous, default Y byte 8 = File is opened with OPT=REVERSED (R) bytes 9-12 = Unused

13 - 14
Index node size for MSORT and TISAM files; unsigned binary
15 - 16
The minimum record size (COBOL files only)
17
Duplicate number width for MSORT and TISAM files
18-19
Current commit counter
20-21
Channel's commit count, non-zero if overridden by the CTC=option, otherwise zero
22-44
Unused
45 +
Sort sequence definitions for MSORT and foreign ISAM files; variable in length based on key sequence definitions:
45
Total length of key, unsigned binary
46
Total number of segments in this key sequence; unsigned binary
47
Data type of keys:

$00$ = string

48 - 67
Sort-name
68 - 75
Key Flags, contain Y or N:

byte 68 = Key may be modified
byte 69 = Duplicate values are allowed
bytes 70-75 = Unused

76 - 83
Unused
84 - 91
Key segment definition (8-byte repeating fields):

byte 84 = Field number (0 = no field number specified), unsigned binary

bytes 85-86 = Offset in field, 1-based, unsigned binary
byte 87 =

Length of segment, unsigned binary

byte 88 = A = ascending, D = descending bytes 89-91 = Unused

Option 4 was added with version 8.6.0. The data for option 4 is returned in the following format:

Byte(s)
Description
1
Link flags:

’ ’ = not opened with OPT=LINK or OPT=DLINK
‘L’ = channel opened with OPT=LINK
‘D’ = channel opened with OPT=DLINK

2
Text flag:

’ ’ = TEXT option not specified
‘T’ = channel also opened with TEXT option

3
Create flag:

’ ’ = CREATE option not specified
‘C’ = channel also opened with CREATE option

4
Alias flag:

’ ’ = ALIAS= option not specified
‘A’ = channel also opened with ALIAS= option

5
Data file flag:

’ ’ = DATA-FILE= option not specified
‘D’ = channel also opened with DATA-FILE= option

6
Sort file flag:

’ ’ = SORT-FILE= option not specified
‘S’ = channel also opened with SORT-FILE= option

7
Text file flag:

’ ’ = TEXT-FILE= option not specified
‘T’ = channel also opened with TEXT-FILE= option

8
Server ID flag:

’ ’ = SID= option not specified
‘S’ = channel also opened with SID= option

9
Table name flag:

’ ’ = TABLE-NAME= option not specified
‘T’ = channel also opened with TABLE-NAME= option

10
Commit count flag:

’ ’ = CTC= option not specified
‘C’ = channel also opened with CTC= option

11
Reversed flag:

’ ’ = REVERSED option not specified
‘R’ = channel also opened with REVERSED option

12 - 16
Reserved for future use
17 - 24
Link name
25 - 33
Format name ( as #FORMAT or %FORMAT )
34 - 49
Reserved for future use ( Screen name, View name )
50 - 57
I/O Trigger name
58 - 65
File suffix method
66 - 67
Client/Server ID
68
Basic File type:

‘I’ = Dictionary-IV ( i.e. DIRECT, SORT or INDEXED )
‘M’ = MSORT
‘T’ = TISAM
‘U’ = Unix (i.e. TEXT)

69
Basic File key size, unsigned binary Note: This may be different from primary key size because of key size adjustment for text fields
70 – 71
Basic File record size, unsigned binary
72 – 75
Basic File number of record, unsigned binary
76
Primary key size, unsigned binary
77
Secondary key size, unsigned binary
78
Number of sort keys, unsigned binary Note: This includes SORT0 for keyed files
79
Maximum sort key size, unsigned binary
80
Data file name length, unsigned binary
81 – a
Data file name
A
Sort file name length, unsigned binary
A+1 – b
Sort file name
B
Text file name length, unsigned binary
B+1 – c
Text file name
C
Table name length, unsigned binary
C+1 – d
Table name

The data for option 5 is returned in the following format:

Byte(s) Description
1 - n Standard FID function data format (see FID function)
(n + 1) Hexadecimal zero ($00$)
(n + 2) + Standard XFD function data format for option 3 (see above)

The data for option 6 is returned in the following format:

Byte(s)
Description
1
File type code, in hexadecimal, as follows:

$00$ = INDEXED
$01$ = SERIAL
$02$ = DIRECT or SORT
$03$ = TEXT
$04$ = PROGRAM
$06$ = MSORT
$07$ = TISAM and compatible files
$0A$ = Directory
$0B$ = System file

2
Keysize; unsigned binary
3 - 6
Number of records; binary
7 - 8
Number of bytes per record; binary
9 +
Filename

The data for option 10 is returned in the following format:

Bytes(s)
Description
1 - 5
Number of records in active use; binary

Depending on the File System that the file was opened to, the information is returned according to the following table:

File Type
RMS files on OPEN VMS not All other file types using Sequential Undefined
SERIAL
Ndefrecs Ndefrecs
INDEX
-1 Ndefrecs
DIRECT
-1 Nrecs
SORT
-1 Nrecs
MSORT (*1) -1Nrecs or -1
TISAMTISAM files cannot be createdNrecs
TEXTTEXT files cannot be created-1
PROGRAMProgram files cannot be created1
SYSTEM-1-1
DIRECTORY NrecsNrecs
Ndefrecs
The number of defined records at the time that the file was created.
Nrecs
The actual number of records in use.
-1
The number of records for this file type is undefined.
*1
For MSORT files that were created with the maximum number of records equal to 0, this function returns a -1.
100 OPEN(1)"IDDBD"
200 LET A$ = XFD(1,0)
300 PRECISION 4
400 LET A = DEC(A$(60,6))/10000
500 PRINT NTD(A,"MM/DD/YY HH:MM:SS")

This example produces the last access date of the IDDBD file. It also illustrates how to convert a date in SQL format to “English” format. Help for converting SQL dates is found in the date type option of Format Definition Maintenance in Dictionary-IV.

FILE and INITFILE directives
DSD, FID, and FST functions

From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF