Skip to main content

Enactor Script Special Variables and Values

Beyond the this, super, and global scope modifiers, Enactor Script provides a handful of predefined variables, "magic" values, and built-in helpers that make scripts easier to write and introspect.

Special Members of 'this' Type References

Every this type reference exposes a few "magic" members that give you information about its context. These are mainly used for introspection and tooling rather than everyday script logic:

  • this.variables - the names of the variables defined in the current namespace
  • this.methods - the names of the methods defined in the current namespace
  • this.namespace - a reference to the current namespace object
  • this.caller - a reference to the calling method's context
  • this.callstack - the chain of namespace references leading up to the current context

Undefined Variables

You can check whether a variable has been given a value at all by comparing it to the special value void:

if ( foobar == void )
// undefined

The unset() command explicitly returns a variable to this undefined state:

a == void; // true
a = 5;
unset("a"); // note the quotes
a == void; // true

Setting the Command Prompt

Where Enactor Script is hosted in a context that has an interactive prompt, that prompt can be customised - either by setting a prompt variable, or by defining a getPrompt() method that returns the string to display.

getPrompt() { return cwd + " % "; }

If getPrompt() is not defined, the host falls back to the prompt variable if it is set, or a default prompt string otherwise.