ASPCompiler ASPCompiler 1.0
ASP Compiler 1.1 documentation is under development. See also the examples.

Variables and GlobalVariables collections

These namespaces of the CTS (both: embedded and file attached) are references to the collections (sections) in the Project tree. They contain by default set of named string values that can be set in the Project settings dialog box (GlobalVariables) and File options dialog box (Variables).

For example if for the current file the variables alpha, beta, gamma are set to values "value1", "value2", "value3" respectively
variables-dlg.gif (5603 bytes)
then the statement:

v = Variables("gamma")

will set the variable v to the string "value3".

If a variable with the same name is not defined for the entire project - replacing the Variables with GlobalVariables in the above statement will set v empty.

(we will use the Variables collections below but the same is applicable for the GlobalVariables collection)

Thus the variables in these collections can be accessed as follows:

to get the variable value:
variable = Variables("variable_name")
or
variable = Variables.Item("variable_name")
The Item is the default property of the collection.

to set the variable value:
Variables("variable_name") = expression
or
Variables.Item("variable_name") = expression
If the variable does not exist it will be created. If it exists the variable value will be set.
expression can be anything - including objects or another collections. While the variables can be set to strings only in the Project settigs or the File options dialogs - the Commpile Time Scripts can set variables to any value they need.

The variable will remain set till the end of the current build.

As any other collection Variables and GlobalVariables can be used in For Each cycles:

For Each v In Variables
  Compiler.ReportMessage 0, v & " = " & Variables(v)
Next

This code will show one message per each variable defined for the current file.

The both collections are implemented using the VarDictionary object - see the other methods and properties in the VarDictionary documentation.

newObjectsSite4All.nl Copyright 2001-2006 newObjects [ ]