VariableCollection
A collection of variables in the model.
Example
application = cf.Application.GetInstance() project = application:NewProject() -- List all predefined variables in the application with their expressions for key,var in pairs(project.Definitions.Variables) do print(tostring(var).." = "..var.Expression) end
Inheritance
The VariableCollection object is derived from the Object object.
Usage locations
The VariableCollection object can be accessed from the following locations:
- Collection lists
- ModelDefinitions object has collection Variables.
Property List
Method List
- Add (expression table)
- Create a variable from the given expression. (Returns a Variable object.)
- 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.)
- Add (name string, other Variable)
- Create a variable using another variable's label as expression. (Returns a Variable object.)
- Contains (label string)
- Checks if the collection contains an item with the given label. (Returns a boolean object.)
- Delete ()
- Deletes the entity.
- Duplicate ()
- Duplicates the entity. (Returns a Object object.)
- GetProperties ()
- Returns a table of properties representing the state of the object. The properties table can be used with the SetProperties method to change multiple properties of the object in one step. (Returns a table object.)
- Item (index number)
- Returns the Variable for the given index in the collection. (Returns a Variable object.)
- Item (label string)
- Returns the Variable for the given label in the collection. (Returns a Variable object.)
- Items ()
- Returns a table of Variable items. (Returns a UnsupportedType(List of Variable) object.)
- SetExpressions (variablelist Map)
- Change the expressions for several variables simultaneously.
- SetProperties (properties Object)
- Modifies the state of the object using the provided table of properties. This method is used to modify multiple properties of the object in a single step.
- UniqueName (label string)
- Generates a unique name base 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 string object.)
Static Function List
- GetDefaultProperties ()
- Creates a table containing the default settings to create an object. (Returns a table object.)
Property Details
Method Details
- Add (expression table)
- Create a variable from the given expression.
- 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 new 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.
- Add (name string, other Variable)
- Create a variable using another variable's label as expression.
- Contains (label string)
- Checks if the collection contains an item with the given label.
- Delete ()
- Deletes the entity.
- Duplicate ()
- Duplicates the entity.
- Return
- Object
- The new (duplicated) entity.
- GetProperties ()
- Returns a table of properties representing the state of the object. The properties table can be used with the SetProperties method to change multiple properties of the object in one step.
- Return
- table
- A table defining the properties.
- Item (index number)
- Returns the Variable for the given index in the collection.
- Item (label string)
- Returns the Variable for the given label in the collection.
- Items ()
- Returns a table of Variable items.
- Return
- UnsupportedType(List of Variable)
- The list of items in the collection
- SetExpressions (variablelist Map)
- Change the expressions for several variables simultaneously.
- Input Parameters
- variablelist(Map)
- The map of variable names with the updated expressions.
- SetProperties (properties Object)
- Modifies the state of the object using the provided table of properties. This method is used to modify multiple properties of the object in a single step.
- Input Parameters
- properties(Object)
- A table of properties defining the new state of the object.
- UniqueName (label string)
- Generates a unique name base 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.
Static Function Details
- GetDefaultProperties ()
- Creates a table containing the default settings to create an object.
- Return
- table
- A table containing the default properties.