FILEDIALOG must explicitly denote file type

Discussions about the Liberty BASIC language, with particular reference to LB Booster
Tasp
Posts: 16
Joined: Sun May 31, 2020 4:51 pm

FILEDIALOG must explicitly denote file type

Post by Tasp »

This caught me out earlier,
While the LBB help does state the template determines which files are listed, in LB this works differently, so highlighting the issue so others don't have to spend time working this out.

LBB Help;
FILEDIALOG "Title", template$, returnvar$
Displays a file selector dialog. The template$ determines which files are initially listed, e.g. "*.bas;*.bbc". On return returnvar$ contains the selected file, or an empty string if the user pressed Cancel.

Often I don't specify the filetype, ie, when the user can select any file from a folder, when using LB 4.5.2, the code below will open a dialog that goes into the folder specified within WavPath$, it also lists all files within the folder, without need for the wildcard *.*
Running this in LBB 3.10 just does not open the FILEDIALOG when the button is pressed.

Code: Select all

WavPath$ = DefaultDir$ + "\F1\F2\"
BUTTON #conf.selwav, "Select Wav", [SelectWav], UL, 60, 230, 80, 30
Open "Window" for Window as #conf
    ConfigWindowOpen = 1
    #conf "trapclose [CloseConfig]"
WAIT

[SelectWav]
FILEDIALOG "Open Wav file", WavPath$, WavFilename$
PRINT WavFilename$
WAIT

[CloseConfig]
CLOSE #conf
END
In order for this to work in LBB 3.10, you must specify the file extension.

Code: Select all

WavPath$ = DefaultDir$ + "\F1\F2\"

BUTTON #conf.selwav, "Select Wav", [SelectWav], UL, 60, 230, 80, 30
Open "Window" for Window as #conf
    ConfigWindowOpen = 1
    #conf "trapclose [CloseConfig]"
WAIT

[SelectWav]
FILEDIALOG "Open Wav file", WavPath$ + "**.wav", WavFilename$
PRINT WavFilename$
WAIT

[CloseConfig]
CLOSE #conf
END
What is ever stranger, is, running the below code on its own without a button opening it, works just fine!!! :o

Code: Select all

FILEDIALOG "Open Wav file", WavPath$, WavFilename$