CurrentDir$ ( )

Parameters

None.

Description

Returns the current directory.

This is the folder that relative paths in file commands are resolved against. It starts out as the folder your program was launched from (the folder containing your source file when running from the IDE) and moves when you call ChangeDir.

In Original mode the returned path has no trailing slash, except at the root of a drive - remember that when you glue file names onto it. In Extended mode it always ends with a backslash.

A common pattern is to remember it at startup so a tool can wander off with ChangeDir and still find its way home.

Original mode strings use the Windows ANSI code page, which can't spell every folder name - a folder named in Chinese on a Western PC, for instance. CurrentDir$ gives each such folder by its short 8.3 name instead, such as JUEGO~1, which works in every file command. Some drives keep no short names (Windows can turn them off per drive), and there CurrentDir$ stops with a runtime error. Extended mode returns such names in full.

See also: ChangeDir, ReadDir, SystemProperty.

Example

; CurrentDir Example
; ------------------

; CurrentDir$ returns the folder used for relative file operations
Print "Current directory: "+CurrentDir$()

; It follows ChangeDir around
CreateDir "demo_folder"
ChangeDir "demo_folder"
Print "Inside demo_folder: "+CurrentDir$()

ChangeDir ".."
Print "Back where we started: "+CurrentDir$()

; Clean up the demo folder
DeleteDir "demo_folder"
Print "Cleaned up demo_folder"

Print ""
Print "Press any key to close the example"
WaitKey

End

Index