Page 1 of 1

OpenFileRequester not seeing files?

Posted: Sat Mar 26, 2022 3:29 am
by CharlesT
Hi all.

I have this bit of code in a procedure handling menu events:

Code: Select all

FileName$ = OpenFileRequester("Load Image", "", "Bitmap files (*.bmp) | *.bmp | All files (*.*) | *.*", 0)
When the file requester window appears, .bmp is the default file type as expected. However, the actual .bmp files in the directory simply do not appear, until I change the file type to "All files (*.*). I also tried having the default file type be *.txt files, and the same problem occurs (they are not visible until I change to see all file types). Am I doing something wrong?

Thanks in advance.

Re: OpenFileRequester not seeing files?

Posted: Sat Mar 26, 2022 4:11 am
by BarryG
You've got spaces in here:

Code: Select all

 | *.bmp | 
The filter needs to be exact. Remove the spaces, because currently your code is looking for extensions ending with ".bmp ".

Re: OpenFileRequester not seeing files?

Posted: Sat Mar 26, 2022 4:12 am
by CharlesT
Thank you, BarryG!

Re: OpenFileRequester not seeing files?

Posted: Sat Mar 26, 2022 4:24 am
by CharlesT
Just a note to whom it may concern:

In the online documentation, under "parameters" for OpenFileRequester(), there are spaces shown in the filter. See below:
It has to be in the following form : "Text file | *.txt | Music file | *.mus;*.mod"
As BarryG kindly pointed out to me, that will not work correctly. The example code snippet on the same page is, however, correct (no spaces).