public interface VariableFactory
This interface supplies methods to create variable objects.
NOTE: Only use this functionality in a URCap program node (not relevant for an installation node).Modifier and Type | Method and Description |
---|---|
GlobalVariable |
createGlobalVariable(String suggestedName)
Creates a global variable.
|
GlobalVariable |
createGlobalVariable(String suggestedName,
Expression initialValue)
Creates a global variable.
|
GlobalVariable createGlobalVariable(String suggestedName) throws VariableException
Creates a global variable. Registering the variable in PolyScope (by storing it in a DataModel
instance
or using it for the configuration of a built-in PolyScope program node) will make it accessible to all program nodes.
suggestedName
- Suggested name of the variable. Valid names must match regex [a-zA-Z][a-zA-Z0-9_]{0,14} for
a total of 15 characters.VariableException
- In case of an illegal name.GlobalVariable createGlobalVariable(String suggestedName, Expression initialValue) throws VariableException
Creates a global variable.
Registering the variable in PolyScope (by storing it in a DataModel
instance or using it for the
configuration of a built-in PolyScope program node) will make it accessible to all program nodes.
Setting an initial value will make it possible to read from the variable immediately without having to assign a value to it first. This can be useful in various constructs which requires an initial value, e.g. 'var_1 = var_1 + 1' or 'if (var_2 == 0):'.
NOTE: Only use this method in a URCap program node (not relevant for an installation node).suggestedName
- Suggested name of the variable. Valid names must match regex [a-zA-Z][a-zA-Z0-9_]{0,14} for
a total of 15 characters.initialValue
- The expression that will be evaluated in order to initialize the value of the variable.
This value is assigned before the actual program runs.VariableException
- In case of an illegal name.Copyright © 2023. All rights reserved.