open

Prev Next

Function Names

open

Description

This function opens a file name with the default application as configured in the operating system or graphical user interface. The application runs in a different process and B4P will not wait until the process has ended, allowing to open multiple files at the same time. For example Excel files with file type .xlsx could be opened with Excel, and .html files with the default web browser.

Opening .b4p programs will start them as separate and independently running processes. When specifying multiple B4P files, then all of them will be opened as new tasks with new terminal windows.

Note: Do not include quotation marks in the path or file name, e.g. with help of the quote path() function.
Note: The default web browser is the one configured in the operating system settings and not B4P, e.g. using the browser() function.

Call as: procedure or function

Restrictions

Indirect parameter passing is enabled.

OS differences

The choice of applications may differ among operating systems and supported applications

Parameter count

Min 0

Parameters

No.TypeDescription
1, ...
input
string File name

The specified file will be opened. Add further file names into futher function parameters in order to open them, too.

Return value

TypeDescription
numeral Return code

The return code of the last file opened 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_open.b4p in B4P_Examples.zip. Decompress before use.

See also

quote path