File Filter Format for FILEFILTER

Top  Previous  Next

This section describes the format of the file filter for the FILEFILTER keyword.

 

A file mask or file filter is a file name that usually includes wildcard characters (*.TXT, for example). Only files that match the selected file filter are displayed in the dialog box's list box, and the selected file filter appears in the File Name edit box. To specify a file filter, assign a filter string as the value of the Filter. To create the string, follow these steps:

 

1        Type some meaningful text that describes the type of file.

2        Type a | character (this is the "pipe" or "or" character).

3        Type the file filter.

 

Don't put in any spaces around the | character in the string.

Here's an example:

 

Text files|*.TXT

 

If you entered the preceding example as the filter, the string "Text files" appears in the List Files of Type drop-down list box when the dialog window appears, the file filter appears in the File Name edit box, and only .TXT files appear in the list box. You can specify multiple file filters so that a list of filters appears in the List Files of Type drop-down list box or in the filter combo box. This allows the user to select from a number of file filters and determine which files are displayed in the list box.

 

To specify multiple file filters,

 

1        Create a file filter string as previously shown.

2        Type another file filter in the same way, but separate the second file filter from the first with the | character.

3        Continue adding as many file filters as you like, separating them with the | character. The string can contain up to 255 characters.

 

Here's an example of three file filters specified as the value of the Filter property:

 

Text files (*.TXT)|*.TXT|Report files (*.RPT)|*.RPT|Output files (*.OUT)|*.OUT

 

Now when the dialog box appears, the user can choose from the three file filters that appear in the List Files of Type drop-down list box.

Note that the previous example includes the file filters in parentheses in the text parts. This isn't required, but it's a common convention that helps users understand what to expect when they select a file filter.

You can string multiple wildcard file filters together if you separate them with semicolons:

 

All supported files|*.TXT;*.RPT;*.OUT