Page 1 of 1

OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 2:23 pm
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

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 4:25 pm
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'.

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 6:16 pm
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$)

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 7:15 pm
by Seymour Clufley
As long as it's spelled "separator"...!

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 8:22 pm
by USCode
See my 3rd enhancement request in this post from almost 8 years ago!
http://www.purebasic.fr/english/viewtop ... =delimiter
:wink:

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 9:41 pm
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

Re: OS depending Pathseperator() command

Posted: Sun Feb 12, 2012 11:00 pm
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.