I just upgraded to Xojo 2015r3.1 and discovered a bug in ShowModal. Here’s the code:
[code]Dim dlg as New SaveAsDialog
dlg.InitialDirectory = SpecialFolder.Documents.Child("My Real Studio").Child("A.Puzzles")
dlg.promptText = "Name your puzzle"
dlg.SuggestedFileName = "Puzzle name"
dlg.Title = "Puzzle name"
dlg.Filter = FileTypes1.ANAX
f = dlg.ShowModal()[/code]
When I run it I get the same result for “f.name” each time – “A.txt” – which is not what I’m inputting in the modal. The “A.” comes from the Child folder title, “A.Puzzles.” If I remove the last Child then the problem goes away.
Is this a bug? I have run this code for years without this problem.
[quote=230876:@Paul Lefebvre]I’m not seeing that behavior here.
Is “A.Puzzles” a folder? If not, why is it set as a folder for the InitialDirectory?[/quote]
“A.Puzzles” is indeed a folder … and it has functioned properly that way for years with this same coding. If I rename the folder removing the period, everything works.
I just created “My Real Studio” folder with “A.puzzles” as a folder in it. When I run the code and click Save in the dialog, I get back the default name that is specified as the default: “Puzzle name.puzzle”
This is my code:
Dim dlg as New SaveAsDialog
dlg.InitialDirectory = SpecialFolder.Documents.Child("My Real Studio").Child("A.Puzzles")
dlg.promptText = "Name your puzzle"
dlg.SuggestedFileName = "Puzzle name"
dlg.Title = "Puzzle name"
dlg.Filter = FileTypes1.ANAX
Dim f As FolderItem
f = dlg.ShowModal()
Break
I do believe Eil is right. There’s a problem with the Filetype class. I will look over your code, Paul, and try re-setting the filetype as you have shown. I was out of the programming loop for the last couple years and am unfamiliar with this new method of setting filetypes, but it looks straightforward enough.
I did find that by deleting the line in my code about filetypes, things began working again.
Thanks for the help, Paul and Eli. I do appreciate it.
Well, I duplicated what you did, Paul, and I’m still getting errants results. But there is a slight change: now instead of the f.name being “A.txt” it’s “A.Puzzles”. So I guess that’s progress, huh?
Not really, of course. It’s still just taking the first part of the folder name (up to the dot) and then adding on the extension. I’m still thinking there’s a bug here.
It’s quite clear to me now that the dot in the folder name is throwing off the filetype info somehow. I’m puzzled that you can get it to run correctly, Paul. I cannot.
If it is indeed a problem of filetype, you may want to try with special/any which accepts everything. If the bug goes away, then you will be certain that is where the problem was.
I am using OS X 10.11.1 and it is working fine there.
But I just tried Windows 10 and I also see A.puzzle get returned instead of “Puzzle name.puzzle”.
Changing it to use a folder called “A-Puzzles” instead of “A.puzzles” seems to work OK. So it would appear that using a folder name with an extension on Windows (which I feel is a bit of an unusual practice) is causing trouble.