Navigation:  The Buzz > Operating System > FileDlg Default Directory >

Using Multiple Files

Previous pageReturn to chapter overviewNext page

Mar 4, 2004  Re: [magicu-l] Re: Simple how to use filedlg function 76240

Late to the party, but... it gets even better:

 

Do you want to have MULTIPLE filter selections in the "Files of type" box?

 

The trick is to "overload" the FILEDLG() function's second parameter with

multiple pairs of arguments, each separated from the next with CHR(0). For

example, suppose you want to have the dialog initially open in the folder

specified in a string variable (let's call it variable A) and you want the

following TWO filter options to appear in the open file dialog's "Files of

type" box:

 

"Dictionary Files (*.ddf)"

"All Files (*.*)"

 

Then, use the following expression:

 

FILEDLG ('Dictionary Files (*.ddf)',

TRIM(A) & '*.ddf' & CHR(0) & 'All Files (*.*)' & CHR(0)& '*.*')

 

The FILEDLG() function's first parameter is a "normal" one, providing the

[first] string to be displayed in the "Files of type" box. BTW, this

string can literally be any string you want, that is, it does not

necessarily need to contain any wildcard characters. It's for display only.

 

The second parameter is where the sleight-of-hand takes place: it's an

aggregate of three "segments" of data, each separated from the next by CHR(0).

 

The first segment of the second parameter is the actual filter condition

associated with the first "Files of type" entry. Note that this segment

also contains the "open in" folder information specified in variable A and

that it is terminated with CHR(0). The folder info provided by variable A

must be a string in the form of "C:\MYFOLDER\" including the terminating

backslash, but not including the double quotes shown here. Don't forget to

TRIM().

 

The second segment of the second parameter provides the second string to be

displayed in "Files of type" box, terminated by CHR(0). Again, this string

can be whatever you want - it's for display only.

 

The third segment of the second parameter string entry is the actual filter

condition associated with the second "Files of type" entry, This (and any

subsequent filter specifications) should NOT contain folder information.

 

Finally, you're not limited to two options. If you want more options, add

more "files of type" descriptions and wildcard filters pairs, separated

from the previous and from each other with CHR(0).

 

Try it - way cool!

 

Steve Blank

 

--------------

 

The example I posted was copied straight out of a Magic 7.11h application

and I just verified that the technique also works in Magic v8.3

SP12. However, you're right, it doesn't work in Magic v9.3, at least not

in SP5h. It DOES however, again work in Magic v9.4 SP2a. Luck o' the draw.

 

Steve Blank

 


Page url: http://www.magic-iug.com/MIUGWeb3/index.html?hm_using_multiple_files.htm