Using the reply parameter
Simple Method
The simple method lets you specify a single default file name or a single simple file filter. The following examples illustrate the simple method. All of the following examples use Windows conventions for specifying directories. On non-Windows systems, you must use the conventions of the operating system. Some examples are:
/*
** To specify a single default file, simply
** specify the file name.
** Enclosing the file name in double quotes, as
** in the advanced method, will also work.
*/
reply.Value = 'myfile.txt';
/*
** You may also specify a default directory along
** with the default name.
*/
reply.Value = 'c:\tmp\myfile.txt';
/*
** You may also specify a single simple file
** filter.
*/
reply.Value = '*.txt';
/*
** The filter specification may also include a
** directory.
*/
reply.Value = 'c:\mystuff\*.txt';
In all cases, a filter of All Files (*.*) is automatically included.
Advanced Method
To describe the advanced method, it is useful to introduce some definitions:
filename
Is the name of a single file. The name may include a path. The name must be enclosed in double quotes.
Examples:
"myfile.txt"
"c:\mystuff\myfile.txt"
filespec
Is a wildcard specification of a set of files. The specification may include a directory specification.
Examples:
*.txt
c:\mystuff\w*.txt
tmp?.*
filespeclist
Is a list of filespecs separated by semicolons. If filespecs are specified in the filter, the dialog will display only files matching these specifications.
The first filespec in the list may contain a directory specification. If so, the dialog will display files from this directory.
Examples:
*.txt
*.img; *.bmp; *.ico
c:\source\*.c; *.ccp
ccfilefilter
Is a filespeclist followed by a text string enclosed in brackets ([ … ]). The opening bracket must immediately follow the last filespec with no intervening spaces. The text string within the brackets is a description of the filter.
Examples:
*.txt[Text Files]
*.img; *.bmp; *ico; *.gif[Image Files]
c:\source\*.c; *.ccp[Source Files]
filterlist
Is a list of ccfilefilters separated by spaces or commas. If multiple ccfilefilters are specified, the first one will be applied when the dialog is initially displayed. All the ccfilefilters will be available for selection, and will be applied when the user selects them.
Examples:
*.txt[Text Files], *.doc[Word Document]
*.bmp; *.ico; *gif[Image Files]
c:\source\*,c; *.ccp[Source Files], *.h; *.hpp[Include Files]
Finally, we can describe the advanced form of the reply parameter:
reply.Value = 'filename,' + 'filterlist';
or:
reply.Value = 'filterlist';
The optional filename is the default file for the file selection dialog. If the optional filename is specified, none of the filespecs in the filterlist may contain a directory specification. If no filename is specified, only the first filespec in the filterlist may contain a directory specification. In every case, "All Files" (*.*) is automatically added as a filter.
Some examples are:
/*
** This example specifies a filter for selecting
** a bmp, gif, or ico image
*/
reply.Value = '*.bmp; *.gif; *.ico[Image Files]';
ret = CurFrame.FilePopup
(
messagetext = 'File containing image',
reply = reply
);
if (ret = PU_OK) then
myBitmapObject.FileHandle = reply.Value;
else
/*
** User canceled and did not select a file.
*/
endif;
/*
** In this example there are two filters: the first
** displays only c or ccp filetypes, the second
** displays only h or hpp filetypes. The default
** directory is d:\src.
*/
reply.Value = 'd:\src\*.c; *.ccp[Source Files] ' +
'*.h; *.hpp[Include Files]';
ret = CurFrame.FilePopup(reply = reply);
/*
** In this example there is a single filter.
** The default directory is c:\textfiles and
** the default file is newfile.txt.
*/
reply.Value = '"c:\textfiles\newfile.txt", *.txt';
ret = CurFrame.FilePopup(reply = reply);