<< Back Part 5. Where Does a Script Start?
Alintex Script .NET provides the ability to pass arguments (values) to a script. These values can then be manipulated within the script itself.
Specifying Arguments
Arguments are specified on the command line in two ways:-
| • | By specifying one or more values before any command line options or script files are specified. |
ax[w]script [arguments] [options] <script files>
| • | Using the /argument option. |
Both of these are equivalent. For example, all three of the following are passing 3 arguments - apple, orange and banana to the "commandline" script:-
apple orange banana commandline.vbx
> axscript /argument:apple,orange,banana commandline.vbx
> axscript apple orange /argument:banana commandline.vbx
Note: the commandline script is in the tutorial folder
The /argument option is especially useful if you want to pass an argument with what looks like a file name to a script. Without it, Alintex Script cannot determine if you a specifying a file as an argument, or are trying to specify a script file.
> axscript myFile.txt commandline.vbx [script or argument?]
> axscript /argument:myFile.txt commandline.vbx
The first example above will generate an error as Alintex Script is unsure about how to deal with myFile.txt. The second example, passes the value myFile.txt as an argument to the script.
If you wish to pass an argument which contains multiple words or spaces, then place the argument within "quote" characters.
Accessing Arguments in Your Script
The arguments supplied on the command line are passed in to the script as a list (array) of strings. See your programming reference or .NET documentation for more information on arrays and strings.
If your script uses a , then you can access arguments within the region using a variable named "args", which is automatically made available. For example, the "commandline" script in the tutorial folder, displays the number of arguments and then displays them as shown below.

If you are using a traditional class/module/method entry point rather than a script #region, then you access command line arguments in the same way as any normal .NET application. See the "hello" scripts in your tutorial folder, for examples of declaring a variable "args" as a parameter to a traditional entry point.
Arguments with JScript.NET
JScript.NET does not support script #regions because it supports global code - the ability to write code which isn't in a class or other type.
So how do you access command line arguments?
One of the .NET Framework Class Library (FCL) classes - System.Environment - has a method GetCommandLineArgs() which would seem to return the command line arguments, however with JScript.NET, the method returns all items from the command line.
One is unable to differentiate easily between arguments, options and scripts.
The answer is to use one of the language extensionScriptHost class contains a property named Arguments that accurately returns the arguments specified on the command line.
See the commandline.jsx script in your tutorial folder, for an example of using that property.
Language Specific Issues - JScript.NET