OpenFileRequester not seeing files?

Just starting out? Need help? Post your questions and find answers here.
CharlesT
User
User
Posts: 20
Joined: Sun Jan 07, 2018 10:09 pm

OpenFileRequester not seeing files?

Post 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.
BarryG
Addict
Addict
Posts: 4218
Joined: Thu Apr 18, 2019 8:17 am

Re: OpenFileRequester not seeing files?

Post 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 ".
CharlesT
User
User
Posts: 20
Joined: Sun Jan 07, 2018 10:09 pm

Re: OpenFileRequester not seeing files?

Post by CharlesT »

Thank you, BarryG!
CharlesT
User
User
Posts: 20
Joined: Sun Jan 07, 2018 10:09 pm

Re: OpenFileRequester not seeing files?

Post 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).
Post Reply