
Script
IScript
Script Methods
| Script() | Constructor for the Script class |
| Name() | Returns the full name of the file associated with the running script |
| NumArgs() | Returns number of commmand line arguments on the Aztec VM command line (-arg xxx) |
| GetArg() | Returns a single command line argument from Aztec command line given one based index |
| IsFlag() | Returns true if the specified flag was used on the Aztec VM command line (-flag xxx) |
| OSVar() | Returns the value of the operating system environmental variable as a string |
| SetOSVar() | Sets the value of the OS environmental variable |
| OSName() | Returns the OS name and version in a string |
| OSExec() | Executes the OS command or launches application |
| RegisterOSFileType() | Registers an application for a specific file type with the operating system |
| CPUName() | Returns the name of the CPU as a string |
| VMVersion() | Returns the Aztec Virtual Machine version as a string (e.g. "1.0") |
| RandomInt() | Returns a random integer within a specified range |
| VMLog() | Returns a reference to the VMLog object to control the VIrtual Machine log file |
| Thread() | Returns reference to currently executing thread |
| MainThread() | Returns reference to the main thread of the script |
| Display() | Returns reference to the local Display object |
| WriteLog() | Writes a text string to the script's log |
| SendTextMessage() | Sends a text message to the script |
| SendObjectMessage() | Sends an object message to the script |
| AddTextMessageHandler() | Registers an event handler for receiving a text message using a method reference |
| AddTextMessageHandler() | Registers an event handler for receiving a text message using an IScript reference |
| AddObjectMessageHandler() | Registers an event handler for receiving an object message using a method reference |
| AddObjectMessageHandler() | Registers an event handler for receiving an object message using an IScript reference |
| OnTextMessage() | Method to handle TextMessage events |
| OnObjectMessage() | Method to handle ObjectMessage events |
IScript Methods
| OnTextMessage() | Abstract method to handle TextMessage events - must be overridden |
| OnObjectMessage() | Abstract method to handle ObjectMessage events - must be overridden |
Derived Classes
None
See Also
Class Hierarchy, Thread, Display, TextMessageEvent, ObjectMessageEvent, Global Methods
public method Script()
Parameters
None
Return Value
None
Description
Constructor for the Script class. The one and only Script object is created internally by the VM and is available using "GetScript()" and "Thread.Script()".
Script Class
public method<string> Name()
Parameters
None
Return Value
Name of the script's main file
Description
This method returns the name of the script. This is the name of the Aztec source or binary file which is listed first on the Aztec command line.
Script Class
public method<int> NumArgs()
Parameters
None
Return Value
Number of command line arguments
Description
This method returns the number of "-arg" arguments specified on the Aztec commmand line. Each instance of "-arg" can contain one or more values, and there can be multiple instances of "-arg". This method returns the total.
Script Class
public method<string> GetArg(int Index)
Parameters
Index
One based index of the argument
Return Value
Argument from command line for specified index
Description
This method returns the "-arg" argument on the Aztec command line for the specified one based index. If the index is not within the range of 1 to "NumArgs()", the method returns an empty string.
Script Class
public method<bool> IsFlag(string Flag)
Parameters
Flag
Name of flag from command line
Return Value
Returns true if the flag is used on command line
Description
This method returns true if the specified Flag was specified on the Aztec command line using the "-flag" option and returns false if not.
Script Class
public method<string> OSVar(string Variable)
Parameters
Variable
Name of OS environment variable
Return Value
Returns the value of the environment variable
Description
This method returns the value of the operating system environment variable specified by 'Variable'. If it doesn't exist, the method returns an empty string.
Script Class
public method SetOSVar(string Variable, string Value)
Parameters
Variable
Name of OS environment variable
Value
New value for OS environment variable
Return Value
NONE
Description
This method sets a new value for the environment variable. If the variable doesn't exist, it creates it and sets the value. This method only sets the environment variable within the scope of the running application, and any OS applications subsequently launched from it.
Script Class
public method<string> OSName()
Parameters
None
Return Value
Returns the name of the operating system
Description
This method returns the name of the operating system which the Aztec Virtual Machine is running in. This is an OS dependent value, and may or may not include a version number embedded within the string.
Script Class
public method<int> OSExec(string CommandLine)
Parameters
CommandLine
Command to be passed to the OS for execution
Return Value
Returns the error code from the OS
Description
This method executes the specified command with the operating system. The CommandLine represents the entire command line, which includes the OS command or application name together with command line arguments. If the command is executed successfully, a value of zero is returned, otherwise an OS dependent non-zero value is returned.
Script Class
public method<string> CPUName()
Parameters
None
Return Value
Returns the name of the processor
Description
This method returns the name of the processor running the Aztec VM.The format of the name is processor dependent.
Script Class
public method<string> VMVersion()
Parameters
None
Return Value
Returns the version of Aztec VM
Description
This method returns the version of the Aztec Virtual Machine which is executing this script. This will be in the form "1.0" with an optional "alpha" or "beta" designator, such as "1.0 Alpha".
Script Class
public method<int> RandomInt(int LowLimit, int HighLimit)
Parameters
LowLimit
Low end of range for random number
HighLimit
High end of range for random number
Return Value
Returns a random number within range
Description
This method returns a pseudo-random integer within the range specified by the low limit and high limit (inclusive).
Script Class
public method<Thread> Thread()
Parameters
None
Return Value
Reference to the current Aztec Thread
Description
This method returns a reference to the currently executing Thread object.
Script Class
public method<Thread> MainThread()
Parameters
None
Return Value
Reference to the main Aztec Thread
Description
This method returns a reference to the main Thread object in the script
Script Class
public method<Display> Display()
Parameters
None
Return Value
Reference to the local Display object
Description
This method returns a reference to the local Display object. This represents the physical workstation running the VM script, and is used as the default parent for top-level windows.
Script Class
public method WriteLog(string Record)
Parameters
Record
Text record to be written to the log for the Virtual Machine
Return Value
NONE
Description
This method writes a record to the VM log for the entire script. This log is available via the "Show Virtual Machine Log" option in the tray menu (available using the "-menu" command line option) and can also be written to a file.
Script Class
public method SendTextMessage(string TextMessage)
Parameters
TextMessage
String to be sent as message to event handlers
Return Value
NONE
Description
This method sends the specified text string to the script as a message, resulting in all registered text message event handlers to be executed.
Script Class
public method SendObjectMessage(Base ObjectMessage)
Parameters
ObjectMessage
Object to be sent as message to event handlers
Return Value
NONE
Description
This method sends the specified object to the script as a message, resulting in all registered object event handlers to be executed. This can be any type of object, but the handlers can be registered on a class by class basis, so only those handlers which are applicable (based on the ObjectMessage class) will be executed.
Script Class
public method AddTextMessageHandler(TextMessageHandler Handler, Base ExtraObject = null)
Parameters
Handler
Method reference to be executed when the event occurs
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers a method reference to be executed when a text message is sent to the script. An optional object can also be registered which will be sent to each event handler as it is executed.
The TextMessageHandler data type represents a method reference specific to a handler for TextMessageEvent. TextMessageHandler is defined as follows:
public type<method<TextMessageEvent,Base>> TextMessageHandler
Given this definition, the method handler must be defined with the following signature (name can be anything):
public method TextMessageMethod(TextMessageEvent event, Base Extra) { }.
Script Class
public method AddTextMessageHandler(IScript Interface, Base ExtraObject = null)
Parameters
Interface
Reference to an IScript object
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers an IScript interface object to be executed when a text message is sent to the script. An optional object can also be registered which will be sent to each event handler as it is executed.
When a TextMessage is sent to the script, the OnTextMessage() method within the IScript object will be executed.
Script Class
public method AddObjectMessageHandler(ObjectMessageHandler Handler, Base ExtraObject = null)
Parameters
Handler
Method reference to be executed when the event occurs
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers a method reference to be executed when an object message is sent to the script. An optional object can also be registered which will be sent to each event handler as it is executed.
The ObjectMessageHandler data type represents a method reference specific to a handler for ObjectMessageEvent. ObjectMessageHandler is defined as follows:
public type<method<ObjectMessageEvent,Base>> ObjectMessageHandler
Given this definition, the method handler must be defined with the following signature (name can be anything):
public method ObjectMessageMethod(ObjectMessageEvent event, Base Extra) { }.
Script Class
public method AddObjectMessageHandler(IScript Interface, Base ExtraObject = null)
Parameters
Interface
Reference to an IScript object
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers an IScript interface object to be executed when an object message is sent to the script. An optional object can also be registered which will be sent to each event handler as it is executed.
When an ObjectMessage is sent to the script, the OnObjectMessage() method within the IScript object will be executed.
Script Class
public method OnTextMessage(TextMessageEvent MsgEvent, Base ExtraObject)
Parameters
MsgEvent
TextMessageEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This method is the event handler for TextMessageEvent. It is invoked internally as a result of the Script.SendTextMessage() method being executed. This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the Script.AddTextMessageHandler() method register the event handlers which get invoked by this method.
Script Class
public method OnObjectMessage(ObjectMessageEvent MsgEvent, Base ExtraObject)
Parameters
MsgEvent
ObjectMessageEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This method is the event handler for ObjectMessageEvent. It is invoked internally as a result of the Script.SendObjectMessage() method being executed. This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the Script.AddObjectMessageHandler() method register the event handlers which get invoked by this method.
Script Class
public method abstract OnTextMessage(TextMessageEvent MsgEvent, Base ExtraObject)
Parameters
MsgEvent
TextMessageEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This abstract method is the event handler for TextMessageEvent within the IScript interface class. The method which overrides it is invoked for TextMessageEvent within the Script object when the interface object is registered with the Script.AddTextMessageHandler() method.
IScript Class
public method abstract OnObjectMessage(ObjectMessageEvent MsgEvent, Base ExtraObject)
Parameters
MsgEvent
ObjectMessageEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This abstract method is the event handler for ObjectMessageEvent within the IScript interface class. The method which overrides it is invoked for ObjectMessageEvent within the Script object when the interface object is registered with the Script.AddObjectMessageHandler() method.
IScript Class