working directory

Prev Next

Function Names

working directory

Description

If no parameter is provided: Retrieve the working directory path.
If a directory path is provided: Change to a different working directory

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

0 - 1

Parameters

No.TypeDescription
Opt. 1
input
string new path and directory name

This is the path to change directory.

  • Absolute paths: e.g. "C:\Program Files", "/usr/local/bin"
  • Relative paths: e.g. "Temp"
  • One directory back: e.g. ".."
  • Stay in current working directory e.g. "."
  • Combinations of above e.g. "..\lib"

Return value

TypeDescription
string Working directory

Full path name of working directory. It does not have a directory separator symbol at the end.

Exceptions

Specified working directory does not exist or is not accessible

Examples

               echo( working directory() );
               working directory("..");               // One directory out
               echo( working directory() );
               echo("Jump to ", system info[bin directory] );
               working directory(system info[bin directory]); // Absolute path
               echo( working directory() );

Output

C:\Users\zur-b\OneDrive\Documents\Programme\Beyond4P\B4P_Docu_Maker
C:\Users\zur-b\OneDrive\Documents\Programme\Beyond4P
Jump to C:\Program Files\b4p
C:\Program Files\b4p
Try it yourself: Open LIB_Function_working_directory.b4p in B4P_Examples.zip. Decompress before use.

See also

pwd
chdir
cd