OS depending Pathseperator() command

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
FGK
New User
New User
Posts: 4
Joined: Sun Oct 02, 2005 12:04 pm

OS depending Pathseperator() command

Post by FGK »

Hello everybody,

I would like to have a simple build in function for getting the correct pathseperator for the used OS.

Today you have to use CompilerIf to select the right seperator or build up a macro for that case.

How nice could it be to write following?

Code: Select all

 PathName.s = Drive + GetPathSeperator() + "MyFile.ext"
instead something like that:

Code: Select all

CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_AmigaOS
      Seperator = "\"
    CompilerCase #PB_OS_Linux
      Seperator = "/"
  CompilerEndSelect

 PathName.s = Drive + Seperator + "MyFile.ext"
I know there are several workarounds for this, but there allready the most of the usefull commands in the FileSystem Lib
so only this one i miss for multi OS coding
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: OS depending Pathseperator() command

Post by IdeasVacuum »

Well, I don't think GetPathSeperator() specifically would be good because it would make string concatenation lines way too long. It wants to be a very short name constant, like #PS. The compiler should be able to 'take it from there'.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: OS depending Pathseperator() command

Post by Tenaja »

+1...
This is a great idea, and I like your suggestion, IdeasVacuum, of keeping it short. While we can create macros and/or individual defines, in the interest of code flexibility, it would be very convenient to have ALL of these types of os-dependent constants predefined. (Another example would be #EOL and #EOL$)
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: OS depending Pathseperator() command

Post by Seymour Clufley »

As long as it's spelled "separator"...!
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: OS depending Pathseperator() command

Post by USCode »

See my 3rd enhancement request in this post from almost 8 years ago!
http://www.purebasic.fr/english/viewtop ... =delimiter
:wink:
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: OS depending Pathseperator() command

Post by moogle »

Just put at the top of your code

Code: Select all

CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
    	#PS$ = "\"
    CompilerCase #PB_OS_AmigaOS
      #PS$ = "\"
    CompilerCase #PB_OS_Linux
    	#PS$ = "/"
    CompilerCase #PB_OS_MacOS	
    	#PS$ = "/"
  CompilerEndSelect
and then use #PS$


As you can see it's been requested almost 8 years ago so.....
Maybe you'll get it in the next update :lol:


PS - Who the hell is still programming on Amiga OS??? :D
Image
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: OS depending Pathseperator() command

Post by MachineCode »

IdeasVacuum wrote:It wants to be a very short name constant, like #PS.
According to #DOUBLEQUOTE$, I think the team prefers descriptive names, rather than short names.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply