GLBasic forum

Codesnippets => Code Snippets => Topic started by: Hemlos on 2008-Oct-02

Title: dir$=DIRECTORY(), and EXPLORER()
Post by: Hemlos on 2008-Oct-02
code=GLBasic V5+6

Code (returns current working directory) Select

FUNCTION DIRECTORY:
// returns current working directory
// FORMAT: dir$=DIRECTORY()
     RETURN REPLACE$(GETCURRENTDIR$(),CHR$(47),CHR$(92))
ENDFUNCTION


dir$=DIRECTORY()+"subdirectory"
EXPLORE(dir$)
Code (opens explorer in specified directory) Select

FUNCTION EXPLORE: dir$
// opens explorer in specified directory
// FORMAT: EXPLORE(dir$)
     SHELLCMD("explorer.exe "+dir$,TRUE,TRUE,rv)
ENDFUNCTION


Combined for simplicity, opens explorer in working directory
Code (opens explorer in working directory) Select

FUNCTION EXPLORER:
// opens explorer in working directory
// FORMAT: EXPLORER()
     ok$=REPLACE$(GETCURRENTDIR$(),CHR$(47),CHR$(92))
     SHELLCMD("explorer.exe "+ok$,TRUE,TRUE,rv)
ENDFUNCTION
Title: Re: GETCURRENTPATH$()
Post by: Kitty Hello on 2008-Oct-02
why not using:
path$ = REPLACE$("/", "\\")
Title: Re: GETCURRENTPATH$()
Post by: Schranz0r on 2008-Oct-03
Thats to simple with REPLACE :D  :good:
Title: Re: GETCURRENTPATH$()
Post by: Hemlos on 2008-Oct-03
Quote from: Kitty Hello on 2008-Oct-02
why not using:
path$ = REPLACE$("/", "\\")


Code (final working codesnip) Select

FUNCTION HF_GETCURRENTDIR$:
RETURN REPLACE$(GETCURRENTDIR$(),CHR$(47),CHR$(92))
ENDFUNCTION

I had to use character codes, the ascii seems to trigger the debugger, its complaining about arguement #'s
Danke :)
Title: Re: HF_GETCURRENTDIR$() windows readable path
Post by: Kitty Hello on 2008-Oct-06
Right. That's a bug in V5. Fixed in next version.