Standard file path delimiter constant #PATHDELIM$ for PB ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Standard file path delimiter constant #PATHDELIM$ for PB ?

Post by USCode »

How about a standard PB constant of #PATHDELIM$ ?

I try to only write code that is cross-platform. If I ever need to build a file path string, then I could use this PB constant and not have to worry about which platform I'm compiling on.

For example,
On Linux -
#PATHDELIM$ = "/"

On Windows -
#PATHDELIM$ = "\"

On OS X -
#PATHDELIM$ = "/" (MacOS 8 & 9 used ":", OS X allows both)

On Amiga -
#PATHDELIM$ = "/" (is this correct?)

But in code we just use #PATHDELIM$, and so it would be correct for whichever platform we're compiling on:

MyPathString = "HOME" + #PATHDELIM$ + "BACKUP" + #PATHDELIM$ + MyFileName

Or maybe a constant like this already exists???
Thanks,
Brian
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Better Solution:

All PB-Comand should take both ("/" and "\") and convert it automatically to OS-Default.

And a new Command: ConvertPathToOSDefault(Path$).

Edit: BTW: Windows should take both!
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Automatic would be nice and superior solution but...

Post by USCode »

...I like the simplicity of just a platform-specific constant. Besides, there's a better chance of getting this in, it would be a very simple change.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Standard file path delimiter constant #PATHDELIM$ for PB

Post by PB »

> maybe a constant like this already exists???

viewtopic.php?t=8187

Just put the correct delimiter in for each CompilerCase command.
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

Just put the correct delimiter in for each CompilerCase command.
A simple constant would be much simpler.
Post Reply