quote path

Prev Next

Function Names

quote path

Description

This function preconditions path and file names before they can be used for operating system calls. This function takes care of putting names into quoatation marks if spaces are contained, and directory symbols (slash, backslash) are corrected so they fit with the target operating system and you can use them to compose the command to use with the system() function. Your benefit is that you can use neutral path and file names (as is the case with directory and file system functions, too),

Call as: function

Restrictions

Indirect parameter passing is disabled.

OS differences

The OS-specific directory separators and quotation mark rules on names with blanks will be applied accordingly.

Parameter count

1

Parameters

No.TypeDescription
1
input
string Path or file name

This path or file name will be preconditioned

Return value

TypeDescription
string Preconditioned path or file name

Examples

    echo( quote path( "C:/program files/B4P/B4P.exe") );     // Quotation marks added and separators aligned
    echo( quote path( "..\Test Directory\Test123/Subdir") ); // "
    echo( quote path( "Countries/*.xlsx") );                 // Directory separator will be aligned for Windows
    echo( quote path( "Username\Nic\Programs") );            // No changes made (if executed under Windows)
    echo( quote path( "Username/Nic/Programs") );            // Windows: Corrects sepearators.  Linux: Puts into quotation marks

Output

C:\"program files"\B4P\B4P.exe
..\"Test Directory"\Test123\Subdir
Countries\*.xlsx
Username\Nic\Programs
Username\Nic\Programs
Try it yourself: Open LIB_Function_quote_path.b4p in B4P_Examples.zip. Decompress before use.

See also

quote path