dir$=DIRECTORY(), and EXPLORER()

Previous topic - Next topic

Hemlos

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
Bing ChatGpt is pretty smart :O

Kitty Hello

why not using:
path$ = REPLACE$("/", "\\")

Schranz0r

Thats to simple with REPLACE :D  :good:
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

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 :)
Bing ChatGpt is pretty smart :O

Kitty Hello

Right. That's a bug in V5. Fixed in next version.