App

Moduleejs.sys
Definition class App
InheritanceApp inherit Object
Specifiedejscript-1.1
StabilityEvolving.

Application configuration state.

The App class is a singleton class object. The App class is accessed via the App global type object. It provides methods to interrogate and control the applications environment including the current working directory, application command line arguments, path to the application's executable and input and output streams.


Properties

QualifiersPropertyTypeDescription
public static get argsArrayApplication command line arguments. Set to an array containing each of the arguments. If the ejs command is invoked as "ejs script arg1 arg2", then args[0] will be "script", args[1] will be "arg1" etc.
public static get dirPathThe application's current directory.
public static get errorStreamStreamThe application's standard error file stream.
public static get exeDirPathThe directory containing the application executable.
public static get exePathPathThe application executable path.
public static get inputStreamStreamThe application's standard input file stream.
public static get nameStringApplication name. Set to a single word, lower case name for the application.
public static get outputStreamStreamThe application's standard output file stream.
public static get setsearchPathStringThe current module search path. Set to a delimited searchPath string. Warning: This will be changed to an array of paths in a future release.
public static get titleStringApplication title name. Multi-word, Camel Case name for the application suitable for display.
public static get versionStringApplication version string. Set to a version string of the format Major.Minor.Patch-Build. For example: 1.1.2-3.

App Methods

QualifiersMethod
public static chdir(value: Object): Void
 Change the application's Working directory.
public static exit(status: Number = 0): Void
 Stop the program and exit.
public static getenv(name: String): String
 Get an environment variable.
public static noexit(exit: Boolean = true): Void
 Control whether an application will exit when global scripts have completed.
public static putenv(name: String, value: String): Void
 Update an environment variable.
public static serviceEvents(count: Number = -1 , timeout: Number = -1): Void
 Service events.
public static sleep(delay: Number = -1): Void
 Sleep the application for the given number of milliseconds.

Method Detail

static public chdir(value: Object): Void

Change the application's Working directory.

Parameters
value: Object The path to the new working directory.

static public exit(status: Number = 0): Void

Stop the program and exit.

Parameters
status: Number The optional exit code to provide the environment. If running inside the ejs command program, the status is used as process exit status. [default: 0]

static public getenv(name: String): String

Get an environment variable.

Parameters
name: String The name of the environment variable to retrieve.
Returns
The value of the environment variable or null if not found.

static public noexit(exit: Boolean = true): Void

Control whether an application will exit when global scripts have completed.

Description
Setting this to true will cause the application to continue servicing events until the exit method is explicitly called. The default application setting of noexit is false.
Parameters
exit: Boolean If true, the application will exit when the last script completes. [default: true]

static public putenv(name: String, value: String): Void

Update an environment variable.

Parameters
name: String The name of the environment variable to retrieve.
value: String The new value to define for the variable.

static public serviceEvents(count: Number = -1 , timeout: Number = -1): Void

Service events.

Parameters
count: Number Count of events to service. Defaults to unlimited. [default: -1 ]
timeout: Number Timeout to block waiting for an event in milliseconds before returning. If an event occurs, the call returns immediately. [default: -1]

static public sleep(delay: Number = -1): Void

Sleep the application for the given number of milliseconds.

Parameters
delay: Number Time in milliseconds to sleep. Set to -1 to sleep forever. [default: -1]