ConsoleApplication.Run

From Xojo Documentation

Event


ConsoleApplication.Run(Args() as String) As Integer

Supported for all project types and targets.

Code in this event is run when the console app starts running. The console app ends when this event finishes.

Notes

Args is an array of command line parameters that get passed to the application. The first parameter will always be the application itself. The return value will be passed to the operating system as the return value for the entire application. The encoding of Args() is operating system-specific. On NT-based systems, it is UTF-16. On Linux, it will be UTF-8, and so forth.

On macOS and Linux, the Args() array contains the passed arguments as unescaped and unquoted values:

  • Unescaped: some characters need to be escaped to be passed on a terminal command line, i.e. preceded by a backslash character. Args() values contain the character without the leading backslash.
  • Unquoted: instead of escaping some characters, single-quotes or double-quotes can be used. Quotes are removed in Args() values.

Example: passing the following command line from a terminal

/path/to/my/application -a --name="A quoted string parameter" --file=~/An\ escaped\ path

results in the following Args() array:

0: /path/to/my/application
1: -a
2: --name=A quoted string parameter   (Double-quotes are removed)
3: --file=~/An escaped path   (Characters are unescaped)