All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Command line runner

Path: /sdk/samples/asrun/

This samples gives a very basic command line runner for AngelScripts. It currently doesn't allow the user to do very much as it is just a sample, but serves as a good foundation for building a useful command line tool.

It also implements a fully functional command line debugger, with support for setting breakpoints, stepping through the code, examining variables, etc.

- Debugging scripts
- Debugger
- string object
- array template object
- dictionary object
- file object
- filesystem object
- datetime object
- Context manager
- Script builder
- Exception routines
- asIScriptEngine::SetContextCallbacks
- Passing command line arguments to script
- Executing system commands from script
- Implementing a #pragma callback

# Usage

    asrun [-d] <script file> [<args>]
     -d             inform if the script should be runned with debug
     <script file>  is the script file that should be runned
     <args>         zero or more args for the script

These usage instructions are also presented if the tool is executed without any arguments.

The runner will look for the function `int main()` or `void main()` as entry point to execute the script.

# How to debug scripts

To run a script with the debugger, either add the command line argument -d or include `#pragma debug` in the script. When this is done, the debugger will show a prompt like this:

    Debugging, waiting for commands. Type 'h' for help.
    [dbg]>

This will then let you set up breakpoints, step through the code, inspect variables, etc. Type `h` on the prompt to get the list of commands available.

# Add-ons available to scripts

The following add-ons to the script language are available to the scripts run by the command line runner.

- string
- array
- dictionary
- file
- filesystem
- datetime
- co-routines
- exception routines

# Global functions available to scripts

Besides the add-ons listed above, the following functions are also exposed to the scripts.

void print(const string &in line)

Prints a line to the standard output.

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)

Executes a system command.