ID: Q103683
The information in this article applies to:
The GETFILE() function returns the whole path and filename of a selected file. To return only the filename, you can use the procedure shown below to remove the path information.
To return only the filename for the GETFILE() function, you can establish the sample FILENAME procedure shown below in a procedure file. The following code demonstrates how to call the FILENAME() function in a program:
fvar = filename(GETFILE())
? fvar
PROCEDURE filename
PARAMETER mfilename
SET TALK OFF
IF .NOT. EMPTY(mfilename)
position = RAT("\",mfilename)
mfname = SUBSTR(mfilename,position+1)
mpath = SUBSTR(mfilename,1,position)
RETURN mfname && Modify to 'RETURN mpath' to return path only
ELSE
RETURN "No File Was Selected"
ENDIF
PROCEDURE filename
PARAMETER mfilename
SET TALK OFF
SET EXACT ON
IF mfilename <> ""
position = LEN(mfilename)
char = " "
DO WHILE char <> ":"
char = SUBSTR(mfilename,position,1)
position = position - 1
ENDDO
mfname = SUBSTR(mfilename,position+2,(LEN(mfilename) ;
- (position +2)))
mpath = SUBSTR(mfilename,2,position) && Modify to 'RETURN ;
mpath' to return path only
RETURN mfname
ELSE
RETURN "No file was selected"
ENDIF
SET EXACT OFF
Additional reference words: FoxDos FoxWin 1.02 2.00 2.50 2.50a
KBCategory: kbprg
KBSubcategory: FxprgGeneral
Last Reviewed: June 27, 1995