AngelScript
Loading...
Searching...
No Matches
System functions
Note
The system functions are only available in the scripts if the application registers support for it.

Functions

void print(const string &in line)

Prints a line to the standard output. No line feed is added at the end, so the caller must include that in the argument if desired.

On systems that support it, e.g. Windows, the virtual terminal processing is enabled. This allows to change the color of the text that is written to the output, controlling the movement of the cursor, enable line drawing, etc. The commands are given by starting an escape sequence with the character ESC, i.e. character 27 in the ASCII table, or 1B in hexadecimal. Following the ESC is a sequence of bytes that is interpreted by the terminal while rendering the text.

Heres an example on how to change the text color.

  const string YELLOW_ON_RED = "\x1b[101;93m";
  const string STRONG_YELLOW = "\x1b[93m";
  const string RESET_STYLE = "\x1b[0m";

  void main()
  {
          print("This " + STRONG_YELLOW + " is yellow. " + YELLOW_ON_RED + "Now on red background." + RESET_STYLE + "\n");
  }

To learn the possible commands that can be given this way, do a search for "Console Virtual Terminal Sequences" on the internet.

string getInput()

Gets a line from the standard input.

array<string> @getCommandLineArgs()

Gets the command line arguments as an array.

int exec(const string &in cmd)
int exec(const string &in cmd, string &out output)

Executes a system command.

Returns -1 on error or raises an exception. On success returns the exit code from the system commmand.

The second alternative allows to capture the stdout into a string, to be further processed.