change directory commands

Prev Next

Function Names

chdir, cd

Description

If no parameter is provided: Under Windows, the working directory path is printed out. Under LINUX and MacOS, the user home directory is chosen.
If a directory path is provided: Change to a different working directory
Both chdir and cd do exactly the same.

These functions are ideally suited for interactive use.

Call as: procedure

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"

Exceptions

Specified working directory does not exist or is not accessible, will be printed out as a short message

Examples

      include( Short Commands Library );
      echo( working directory() );
      cd("..");                 // One directory out
      echo( working directory() );
      echo("Jump to ", system info[bin directory] );
      chdir(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_chdir.b4p in B4P_Examples.zip. Decompress before use.

See also

working directory