system

Prev Next

Function Names

system

Description

This function executes system commands. It accepts an arbitrary number of function parameters where each of them contains one system command. Calling this function with zero parameters have no effect.

Attention: In the 1980's, file names were limited to 6-8 capital letters and digits. Nowadays, many directory and file names contain spaces and special characters. When using such path names in system commands, they need to be preconditioned in order to avoid confusing path and file names with spaces inbetween as multiple command line parameters, as well as ensuring that the right directory separator symbols (slash or backslash) are used. Use the function quote path() to precondition all path and file names where this function takes care of operating system specific differences.

Call as: procedure or function

Restrictions

Indirect parameter passing is enabled.

OS differences

System commands are operating-system specific. Please refer to the (on-line) user guides and reference manuals of the operating system you are using

Parameter count

Min 0

Parameters

No.TypeDescription
1, ...
input
string System command

This command will be executed. Add further commands into separate function parameters to have them executed one after the other.

Return value

TypeDescription
numeral Return code

The return code of the last command executed will be provided. Typically, 0 refers to successful outcome. -1 is returned if no system command has been executed.

Examples

    path[] = quote path("Examples/*table_lookup*.*");
    echo("Path used for directory: ", path[]);

    if (system info[operating system] = Windows)
    {
        a[] = system( "dir /w /b " + path[] );
    }
    else // Linux, MacOS
    {
        a[] = system( "ls " + path[] );
    }
    echo("Return value is ", a[] );

Output

Path used for directory: Examples\*table_lookup*.*
LIB_Function_table_lookup.b4p
LIB_Function_table_lookup_fast.b4p
LIB_Function_table_lookup_once.b4p
LIB_Function_table_lookup_smart.b4p
LIB_Function_table_lookup_smart_once.b4p
LIB_Function_table_lookup_with_rules.b4p
LIB_Function_table_lookup_with_rules_once.b4p
Return value is 0
Try it yourself: Open LIB_Function_system.b4p in B4P_Examples.zip. Decompress before use.

See also

quote path