Libraries.System.Process Documentation

This class allows us to create a new process on the computer. Essentially, this causes a new running program to be created with its own memory space. We can specify the parameters to be sent to the process and listen to what it is doing.

Example Code

use Libraries.System.File
use Libraries.System.Process
use Libraries.System.ProcessListener
use Libraries.System.ProcessEvent
use Libraries.Containers.Array

class RunIt is ProcessListener
action Main
    Process process
    process:SetName("C:\location\node")
    
    File folder
    folder:SetAbsolutePath("C:\otherlocation")
    process:SetDirectory(folder)
    
    Array<text> flags
    flags:Add("Result.js")
    process:AddListener(me)
    process:Run()
end

action ProcessStarted(ProcessEvent event)
    output "Started"
end

action ProcessStopped(ProcessEvent event)
    output "Started"
end

action Output(ProcessEvent event)
    output "Standard out: " + event:GetOutput()
end

action Error(ProcessEvent event)
    output "Standard error: " + event:GetOutput()
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

AddListener(Libraries.System.ProcessListener listener)

Adds a listener object that can tell us when the process starts, stops, or outputs information.

Parameters

Cancel()

Terminates the process.

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetDirectory()

This returns the directory in which the process will be run.

Return

Libraries.System.File: the directory in which to run the process.

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetMonitorWaitTime()

By default, output from the process will be batched and sent to our process approximately every 50 milliseconds. This action allows us to override this value to any amount of milliseconds. For example, we might raise this to 1000 if we only need the output from a program every second.

Return

integer:

GetName()

Gets the name of the process.

Return

text: the name of the process.

GetParameters()

Gets the paramters that are passed to the process.

Return

Libraries.Containers.Array: the parameters of the process.

IsAlive()

This returns true if the program is still running.

Return

boolean: true if still executing.

Remove(Libraries.System.ProcessListener listener)

Removes a listener object. This stops us from getting events, but does not change what the process is doing.

Parameters

Run()

This action tells the process to begin its execution. If no file is set, then the current working directory in Quorum (the default in the File class) is used, meaning it will run from wherever the current program is running from. The name of the program to be run and the flags passed are used to run the program, so these must be set before calling Run.

SendInput(text value)

This action sends text to a running process on standard input.

Parameters

  • text value

SetDirectory(Libraries.System.File folder)

Sets the directory in which the process will be run.

Parameters

SetMonitorWaitTime(integer time)

By default, output from the process will be batched and sent to our process approximately every 50 milliseconds. This action allows us to override this value to any amount of milliseconds. For example, we might raise this to 1000 if we only need the output from a program every second.

Parameters

  • integer time: the amount of time to wait, in milliseconds, before output it sent to our listeners.

SetName(text name)

Sets the name of the process.

Parameters

  • text name: the name of the process.

SetParameters(Libraries.Containers.Array<text> flags)

Sets the paramters that are passed to the process.

Parameters

ToText()

By default, this returns just the name of the process.

Return

text: the name of the process