m (1 revision)
Latest revision as of 14:25, 20 June 2011
<var> as <type> [= <value>]
Define a variable
Please also see:
- VAR - a keyword which provides a short-hand way of defining variables where their type is automatically inferred by the compiler.
- A variable name
- One from any of the valid Data Types, such as integer, string, noderef, noderef of class <type>, etc.
- (optional) The value or Expression to which to initialize the new variable
This command is multi-purpose. It can be used to define a variable, or a noderef.
- To define a variable with this method, it must be declared to be of a particular type. If it is desired to declare it without specifying a Data Type, use the VAR keyword.
- To define a noderef, it can be declared in two ways with this method:
n as noderef of class <classname>
n as noderef(or simply:
n as noderef)
- If this method is used, meaning no class is specified, it is important to remember that fields on that noderef cannot be accessed unless the noderef is first classified with a WHERE statement to specify which class that it is.
Important: Defining a node does *not* create a node. It only defines a reference to an existing node. To create a node, it is necessary to use a special function such as
CreateNodeFromClass(<class>). Please see the section on Built-in_Functions for more information. Even then, a node can have any number of classes on it, though the first one it is created as is its "base class".
NOTE: There is also a special case of defining a variable to be a class, even though it is not a node reference. For more information on this, please see the section on Class Level Assignment.
a as int foo as Vector fud as Noderef of class Vector backpackref as noderef = CreateNodeFromClass("container") a as integer = 7 n as noderef of class GUIcontrol n.visible = true n as noderef where n is kindof GUIlabel n.text = "hi there" .