VariableCollection

A collection of variables in the model.

Example

app = cf.GetApplication()
project = app:NewProject()

    -- List all predefined variables in the application with their expressions

for key,var in pairs(project.Variables) do
    print(var.Name.." = "..var.Expression)
end

Usage locations (collections)

The following objects contain the VariableCollection collection:

Property List

Count
The number of Variable items in the collection. (Read only number)
Type
The object type string. (Read only string)

Method List

Add (name string, expression Expression)
Create a variable from the given expression. (Returns a Variable object.)
Add (name string, expression Expression, description string)
Create a variable from the given expression. (Returns a Variable object.)
Contains (label string)
Checks if the collection contains an item with the given label. (Returns a boolean object.)
Item (index number)
Returns the Variable at the given index. (Returns a Variable object.)
Item (label string)
Returns the Variable with the given label. (Returns a Variable object.)
Items ()
Returns a table of Variable. (Returns a List of Variable object.)
SetExpressions (variablelist Map of string:Expression)
Change the expressions for several variables simultaneously.
UniqueName (label string)
Generates a unique name base of of the provided base name.If the base name already exists in the collection, a digit will be appended until a valid name is generated. (Returns a boolean object.)

Index List

[number]
Returns the Variable at the given index in the collection. (Read Variable)
[string]
Returns the Variable with the given name in the collection. (Read Variable)

Property Details

Count
The number of Variable items in the collection.
Type
number
Access
Read only
Type
The object type string.
Type
string
Access
Read only

Method Details

Add (name string, expression Expression)
Create a variable from the given expression.
Input Parameters
name(string)
The variable name.
expression(Expression)
The variable expression.
Return
Variable
The variable.
Add (name string, expression Expression, description string)
Create a variable from the given expression.
Input Parameters
name(string)
The variable name.
expression(Expression)
The variable expression.
description(string)
The variable description.
Return
Variable
The new variable.
Contains (label string)
Checks if the collection contains an item with the given label.
Input Parameters
label(string)
The label of the Variable.
Return
boolean
The success of the check.
Item (index number)
Returns the Variable at the given index.
Input Parameters
index(number)
The index of the Variable.
Return
Variable
The Variable at the given index.
Item (label string)
Returns the Variable with the given label.
Input Parameters
label(string)
The label of the Variable.
Return
Variable
The Variable with the given label.
Items ()
Returns a table of Variable.
Return
List of Variable
A table of Variable.
SetExpressions (variablelist Map of string:Expression)
Change the expressions for several variables simultaneously.
Input Parameters
variablelist(Map of string:Expression)
The variable name.
UniqueName (label string)
Generates a unique name base of of the provided base name.If the base name already exists in the collection, a digit will be appended until a valid name is generated.
Input Parameters
label(string)
The base name.
Return
boolean
The generated unique name label for Variable.