### System

Category

Debugging

Function

Executes a system function.

Syntax

    System(string);

Inputs

Name | Type | Default | Description
--- | --- | --- | ---
`string` | string | none | shell command to be executed

Functional Details

The System module uses the C library `system()` function to execute operating system commands.

If the characters %, \, or " occur in the command string, they must be escaped: the percent sign must be preceded by another percent sign; backslashes and double quotes must be preceded by a backslash.

#### Special note about running Microsoft Window's executables and pathnames.

Because a space can be part of an application's path, it may be required that you quote the path string. Following the convention in the previous paragraph, quotes must be inserted with \" and backslashes will need to use the escaped \ (i.e. \\). There is one exception to this--if the pathname does not contain a space and it starts a full path to the application (letter followed by colon), then non-escaped backslashes may be used. For example acceptable and unacceptable strings, refer to the following:

##### Acceptable:

`"C:\Progra~1\MyApp\RunData.exe datafile.dat"
` `"\"C:\\Program Files\\MyApp\\RunData.exe\\" datafile.dat"
"\"C:/Program Files/MyApp/RunData.exe\" datafile.dat"`

##### Unacceptable

`"C:\Program Files\MyApp\RunData.exe datafile.dat"
(previous needs shortpath used--no spaces)
"\"C:\Program Files\MyApp\RunData.exe\" datafile.net"
(previous needs backslashes escaped)`

Script Language Example

This example creates a sequence of captioned images using different isosurface values. The Format module creates a different image file name for each image. The System module executes the compress function to minimize the amount of disk space used.

    electrondensity = Import("/usr/share/dx/samples/data/watermolecule");
    electrondensity = Partition(electrondensity);
    camera = AutoCamera(electrondensity,resolution=300,aspect=1,width=2.5);
    macro makeiso(isoval)
    {
        isosurface = Isosurface(electrondensity, isoval);
        caption = Format("isoval = %g", isoval);
        caption = Caption(caption);
        imagename = Format("iso%4.2f.rgb", isoval);
        collected = Collect(caption, isosurface);
        image = Render(collected, camera);
        Display(image);
        WriteImage(image, imagename);
        command = Format("compress %s", imagename);
        System(command);
    }
    makeiso(0.1);
    makeiso(0.2);
    makeiso(0.3);
    makeiso(0.33);
    makeiso(0.36);
    makeiso(0.39);

[ OpenDX Home at IBM | OpenDX.org ]