## System

### Introduced

v1.0

### Description

System allows you to run operating system commands, programs or batch files. It is usually used along with the XSIApplication.Platform property in order to achieve maximum portability. XSIApplication.InstallationPath can also be used to minimize usage of hard coded paths.
Your programs and batch files can use the standard exit command to return a value (for example, 'exit(1)' in C/C++, 'exit 1' in shell programing (Unix) or 'exit /b 1' on Windows XP batch files).
Operating system commands usually return 0 for success or any other value for errors. Please consult your OS vendor's documentation for more details.
Note: This command uses output arguments. C# and some scripting languages (such as JScript, PerlScript and Python) don't support arguments passed by reference. However, the return value also provides the output argument.

### Scripting Syntax

    oDouble = System( Pathname, [Value] );

### Return Value

The return value of the executed command, program or batch file as a Double. This value can be used as a means to transmit information from your batch files or custom built applications to Softimage.

### Parameters

Parameter | Type | Description
--- | --- | ---
Pathname | String | Command to be executed. Default Value: none
Value | Double | This optional parameter is equivalent to the return value. It is provided for backward-compatibility only.

### Examples

#### 1. VBScript Example

    ' Creates a text file with the content of the project directory
    Dim cmdResult           ' result of the command line operation
    Dim cmd                         ' command to execute
    Dim destinationPath     ' destination path for the created file
    Dim sourcePath          ' path of the directory used to create the file
    ' source = project path
    sourcePath = Application.InstallationPath( siProjectPath )
    ' output in the user path
    destinationPath = Application.InstallationPath( siUserPath )
    ' create the command line depending on the current platform
    Select Case Application.Platform
            ' Windows
            Case "Win32"
                    cmd = "dir " & sourcePath & " > " & destinationPath & "\content.log"
            ' Linux
            Case Else
                    cmd = "ls " & sourcePath & " > " & destinationPath & "/content.log"
    End Select
    ' run the constructed command
    cmdResult = system( cmd )
    ' Check if everything went fine
    If cmdResult = 0 Then
            LogMessage "Success"
    Else
            LogMessage "Failure"
    End If

#### 2. VBScript Example

    ' Running an application through Softimage
    Dim customApplication           ' the application or batch file to run
    Dim customApplicationParam      ' parameters to pass to your application
    Dim appResult                   ' the return code of your application
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Set the custom application to run.  Put your application
    ' path here.  You could use the Application.InstallationPath
    ' property along with the Application.Platform property to make
    ' your code work on any possible user configurations.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    customApplication = "notepad.exe"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Set the parameters to pass to your custom application.  This can
    ' be nothing if none are required.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ApplicationParam = "c:/content.log"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' execute the application
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    appResult = System( customApplication & " " & ApplicationParam )
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Perform actions according to the return value of the application
    ' The values below must be customised according to the application
    ' or the batch file that ran.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Select Case appResult
            Case 0 LogMessage "Wonderful!"
            Case 1 LogMessage "Error case when 1 is returned"
            Case 2 LogMessage "Error case when 2 is returned"
            Case Else LogMessage "Any other error case"
    End Select

### See Also

XSIUtils.LaunchProcess