Defining variables

From HEWIKI
Jump to: navigation, search

<var> as <type> [= <value>]

Define a variable

Please also see:


Contents

Arguments

<var> 
A variable name
<type> 
One from any of the valid Data Types, such as integer, string, noderef, noderef of class <type>, etc.
<value> 
(optional) The value or Expression to which to initialize the new variable

Description

This command is multi-purpose. It can be used to define a variable, or a noderef.

  • 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".

Classes cannot be defined with this method, since they are in the DOM (Data Object Model). To define a class, it is necessary to use the CLI and the CCD command (for Create Class Definition).

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.


Examples

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"
.

Additional Information

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox