FID

PURPOSE:
To OBTAIN information about an OPENED file or device.
STATEMENT SYNTAX:
{stno}FID(unit)fname, ftype, direntry,#recs, recsiz, disk#, channel#, #keys, 
               keysiz, recsused, #open,#extract

where:
fnamea file or device name
ftype0-device
1-program
2-indexed
3-sort
4-direct
5-string
7-serial
8-mkeyed
105-directory.
direntryDirectory Entry String.
recsnumber of records currently allocated to the file
recsizthe record size in bytes (max 8192)
disk#corresponding to a SETDISK command
channel#OS Channel number
#keysnumber of keys initially allocated to the file
keysizthe key size in bytes (max 120)
recsusedthe number of records and/or keys in use.
#open0 - Not Used
#extract0 - Not Used
EXAMPLE:
0010 FID(9,ERR=999)F$ To retrieve FILE NAME only 
0020 FID (1)F$,T,E$ To retrieve first 3 fields. 
0030 FID (2)*,*,*,*,*,D To obtain Disk Number only.
NOTES:
The FID command is invalid for SOCKET's (returns an error 17)
Devices only return their name.
Directories only return their path name in the fname field.
If some variables are not required, the "*" (skip field) option is available (just like any other I/O command). Parameters that are not applicable will simply yield ZERO OR NULL VALUES as warranted.

The 1st 32 bytes of directory entry are the result of an fstat command, the next 16 bytes are $00$,next 2 bytes) are an SM32 internal type number and the characters starting at byte 51 are the full path name. If a FID(1)*,*,B$ were executed then B$ will contain :
Conversionfstat nameDescription
DEC(SWAP(B$(1,2),$01$))st_devdevice (always = 0)
DEC(SWAP(B$(3,2),$01$))st_inoinode (=0 under windows)
SWAP(B$(5,2),$01$)st_modeprotection see fstat for bit layout
DEC(SWAP(B$(7,2),$01$))st_nlinknumber of hard links (=0 under windows)
DEC(SWAP(B$(9,2),$01$))st_uiduser ID of owner (=0 under windows)
DEC(SWAP(B$(11,2),$01$))st_gidgroup ID of owner (=0 under windows)
DEC(SWAP(B$(13,2),$01$))st_rdevdevice type (always =0)
B$(15,2) $0000$
DEC(SWAP(B$(17,4),$03$))st_sizetotal size, in bytes
DEC(SWAP(B$(21,4),$03$))st_atimetime of last access
DEC(SWAP(B$(25,4),$03$))st_mtimetime of last modification
DEC(SWAP(B$(29,4),$03$))st_ctimefile creation time
B$(33,16) All $00$'s
DEC(SWAP(B$(49,2),$01$))  1000 - indexed
1001 - sort
1002 - direct
1003 - serial
1004 - pipe
1005 - mkeyed1
1006 - smkeyed
1007 - program
1008 - pgmlib
1009 - mkeyed2
1010 - string
1011 - pgmlib_program
1012 - directory
1013 - pgmlib2
1014 - link
B$(51) Path Name

st_atime,st_mtime and st_ctime are in UTC where 0 = Dec 31,1969 at midnight. The example below show how to extract these times using the Date Offset function.
10 BEGIN 
20 OPEN (1)"dtest"
30 FID (1)*,*,B$
40 LET D$=DTO("19700101000000",DEC(SWAP(B$(29,4),$03$)))
50 LET D$=D$(1,4)+"-"+D$(5,2)+"-"+D$(7,2)+" "+D$(9,2)+":"+D$(11,2)+":"+D$(13,2)
60 PRINT B$(51)," was Created: ",D$
70 LET D$=DTO("19700101000000",DEC(SWAP(B$(25,4),$03$)))
80 LET D$=D$(1,4)+"-"+D$(5,2)+"-"+D$(7,2)+" "+D$(9,2)+":"+D$(11,2)+":"+D$(13,2)
90 PRINT B$(51)," was Modified: ",D$
100 LET D$=DTO("19700101000000",DEC(SWAP(B$(21,4),$03$)))
110 LET D$=D$(1,4)+"-"+D$(5,2)+"-"+D$(7,2)+" "+D$(9,2)+":"+D$(11,2)+":"+D$(13,2)
120 PRINT B$(51)," was Accesed: ",D$
SEE:
FID function