Environment STATIC CLASS

A helper class providing runtime information about the current environment.

Parent Class

All Members


TypeNameSignature
field S ClineSeparatorpublic static const String lineSeparator
field S CpathSeparatorpublic static const String pathSeparator
field S Cseparatorpublic static const String separator
method Sevaluatepublic static var evaluate(System.EvalConfig, string, string[])
method SgetAllEnvpublic static Map getAllEnv()
method SgetEnvpublic static String getEnv(string)
method SgetScriptpublic static Script getScript()

Fields


public static const String lineSeparator

The line separator. "\r\n" on Microsoft Windows; "\n" on Unix, Linux, macOS and other Unix-like systems.


public static const String pathSeparator

The separator required by the operating system to enumerate multiple paths. This string always contains a single character: ";" on Microsoft Windows; ":" on Unix, Linux, macOS and other Unix-like systems.


public static const String separator

The separator used by the file system to represent a path. This string always contains a single character: "\" on Microsoft Windows; "/" on Unix, Linux, macOS and other Unix-like systems.


Methods


public static var evaluate(EvalConfig config, string scriptPath, string[] arguments)

Evaluate the given script with customized configuration.

The script must be a module-less script, otherwise this method will throw System.IllegalStateException.

This method can only be called from a module-less script and outside any form of functions, including lambdas. It can indeed be called from inside a nested scope, although any variables defined anywhere other than in the outermost scope won't be visible to the evaluated script.

Consequentially, this method can only be called from the main thread, as there is no way to start a thread that executes some random lines from the global script.

This method provides the finest control over the behavior of dynamic script interpretation. For most scenarios, consider using the two shortcut global functions instead: incl(string) and eval(string, string[]).

Required Policies

  • System.Environment/eval

Parameters

  • config A configuration object to customize the evaluation behavior. In the case of null, it uses the same config as the include statement.
  • scriptPath The path to the script. Must be ended with ".jul". Can be absolute or relative. If relative, it will be resolved against the current script's location, or the default module path, depending on the config.
  • arguments The arguments to be passed to the script, accessible as a global variable with name arguments.

Returns

  • The value returned from the script. If the script didn't return anything explicitly, null will be returned.

Throws


public static Map getAllEnv()

Get all environment vairables.

Required Policies

  • System.Environment/read

Returns

  • All environment variables stored in a map, keyed by the variable name.

public static String getEnv(string name)

Get the value of environment vairable.

Required Policies

  • System.Environment/read

Parameters

  • name The environment vairable's name.

Returns

  • The string value of the environment variable if found, or null if not found.

Throws


public static Script getScript()

Get the script which is running at the line where this method is called.

A method call can only happen at exactly one physical place. If that place is a script file, this method will return the script info for that file.

This method is supposed to be called in the same script of which the information is intended. Of the most importance, do not wrap this method in another method, as that would always return the script file which contains the wrapper method.

Required Policies

  • System.Environment/read

Returns

  • A Script object containing the info about the currently running script.