Local variables are created as part of an expression or an expression block and cannot be accessed from outside of it. However, from within an expression you can refer to any variable that exists in the scope of the expression and its parent scopes.
def String upperVar := "1"; begin def String lowerVar := "2"; upperVar := "3"; end; //this is not correct: //lowerVar := "4";
To create a local variable use the def
keyword in an expression. Note that def
only declares the variable:
The variable value when declared is null
, which is returned as its value.
To assign a value to a variable, use the assignment (:=
) operator: such an expression returns the right-hand-side value of the assignment.
Note: In models, you can define also global and local variables. Global variables are accessible from the entire Model; local variables within the given resource, such as, a process or form. Mind you cannot create global or local variables in the Expression Language; these are created in dedicated model resources.