ProvideX V8.20 > Language Reference > 3. System Functions
430
FFN( ) Function
          Find File Number
Format
FFN(filename$[FOR OBJECT] [,ERR=stmtref])
Where:
filename$
Name of the file to locate. String expression (case sensitive on
UNIX/Linux systems.)
FOR OBJECT   Keyword to return file handles owned by an object. Inside an object the first
reference to the file owned by the object is returned otherwise it will be -1.
stmtref
Program line number or label to transfer control to.
Returns
Integer, channel/file number for open file (-1 if not open).
Description
This function checks all open files for any reference to the filename$ specified. The
function returns the file number as an integer if the file is open. If the file is not
currently open on any channel, FFN( ) returns a value of -1. The filename specified
in FFN( ) must match the name used to OPEN the file; e.g.,
open(1)"cstfile
print "channel is: ",ffn("C:/Program Files/Sage
Software/ProvideX/NOMADS/cstfile") ! Incorrect
channel is: -1
print "channel is: ",ffn("cstfile") ! Correct
channel is: 1
Examples
Read a record from the CUSTDB file. If the file is not open, then open it on a Global
file number.
0100 LET X=FFN("CUSTDB")
0110 IF X=-1 THEN LET X=GFN; OPEN (X)"CUSTDB"
0120 READ (X,KEY=CST_ID$,ERR=9000)IOL=%CST_IOL$
FFN( ) is case-sensitive (as is necessary in UNIX). To perform a case-insensitive
search for the filename, set either 'FL' (lower case) or 'FU' (upper case) parameters.
0100 OPEN (5)"CSTfile" ! With neither 'FL' nor 'FU' set
-:PRINT "channel is: ",FFN("CSTFILE")
channel is: -1
-:SET_PARAM 'FL'
-:PRINT "channel is: ",FFN("CSTFILE")
channel is: 5
-:PRINT "channel is: ",FFN("cstFILE")
channel is: 5