Saving: fileextensions not recognized correctly

Working on new editor enhancements?
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Saving: fileextensions not recognized correctly

Post 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post 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.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

> with the typed ".pb" on the end
I know. But this is somehow annoing...?!
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post 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.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Hm... Yes, you're right.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Well, other apps add the right extension so the PureBasic IDE should too.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

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