FILEREQUEST

Top  Previous  Next

Syntax

STRING = FILEREQUEST(title as STRING,parent as POINTER,nOpen as INT,OPT filter as STRING,OPT ext as STRING,OPT flags as INT,OPT initdir as STRING)

Description

Opens the standard file dialog and returns a string containing the fully qualified pathname to the user-selected file. For a ‘Save as’ dialog nOpen should be 0. For an ‘Open’ type dialog nOpen should be 1.

Parameters

title - Title of the file dialog

parent - Parent window or dialog, can be NULL

nOpen - Open dialog specifier.

filter - Filter string

ext - Default extension

flags - Additional style flags

initdir - Initial directory

Return value

A string containing the full path name to the file or a list of files.

Remarks

The optional filter variable limits the dialog to showing only certain file types. The string consists of ordered pairs separated by the '|' character and ending with two ||.

Example:

Filter$ = "Text files|*.txt|All Files|*.*||"

The default extension string should not contain a '.' and will be used in the 'Save as' dialog is the user does not type an extension.

The only additional style is @MULTISELECT in which case the return string will contain a list of files separated by the bar character '|'. If only one file is selected it will still contain a terminating bar '|'.

See Also: COLORREQUEST, FONTREQUEST

Example usage

REM Define a buffer to hold the returned filenames.
DEF filenames[10000]:ISTRING
DEF filter,filetemp:STRING
DEF pos:int
filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt||"
 
filenames = filerequest("Select Multiple Files",0,1,filter,"txt",@MULTISELECT, "C:\\")
do
    pos = instr(filenames,"|")
    if(pos)
        filetemp = left$(filenames,pos-1)
        filenames = mid$(filenames,pos+1)
        REM do something with the file in filetemp
    endif
until pos = 0