Page 1 of 1
Saving: fileextensions not recognized correctly
Posted: Sun Apr 29, 2007 11:31 am
by AND51
Hello!
Trying to save a file named "TP PToject Manager 2.5" fails. The PB IDE thinks that ".5" is the fileextension, but this is not true. I explicitely selected ".pb or sometimes ".pbi" in the file pattern list, but it still doesn't work.
In other programs (Paint, Notepad) it works.
Posted: Sun Apr 29, 2007 11:55 am
by Derek
When saving it give it the filename 'TP PToject Manager 2.5.pb' with the typed on the end. The editor won't add another '.pb' extension so the file name will be ok.
Posted: Sun Apr 29, 2007 1:59 pm
by AND51
> with the typed ".pb" on the end
I know. But this is somehow annoing...?!
Posted: Sun Apr 29, 2007 2:01 pm
by Derek
Yeah, I know, but if you get used to typing it in all the time it soon becomes second nature and it saves having to check if the extension box is still set right, to .pb I mean.
Posted: Sun Apr 29, 2007 2:04 pm
by AND51
Hm... Yes, you're right.
Posted: Sun Apr 29, 2007 2:25 pm
by PB
Well, other apps add the right extension so the PureBasic IDE should too.
Posted: Sun Apr 29, 2007 3:35 pm
by AND51
Be careful!
Try to save a HTML file with Notepad, for example. Typing "index.html" doesn't work, unless you choose "All files" as file pattern.
In this case, the PB IDE behaviour would be better.
But Notepad does not have the mistake that it interpretes ".5" as pattern.
All in all, I agree with you, PB.
Posted: Sun Apr 29, 2007 4:29 pm
by Trond
This is how it's done in most applications:
Code: Select all
If (Left(name, 1) #DOUBLEQUOTE$ And Right(name, 1) = #DOUBLEQUOTE$) Or pattern = allfiles
name = stripQuotes(name)
savefile(name)
Else
ext = firstextensionincludingdotinselectedpattern()
If Right(name, Len(ext)) = ext
savefile(name)
Else
savefile(name + ext)
EndIf
Of course, savefile() needs to check if the filename is a valid filename.