- Output field : Gets or sets a user-specific temporary variable.
<var>name = expression</var>
- Condition or JS field : Gets or sets a user-specific temporary variable.
var.name = expression;
The var element creates a temporary variable on the fly. The var can be used without needing to define it beforehand. The scope of var is global. It can be used by any cells. The value of var is user specific. Similar to user object, BrainShop mains a var for each user. The lifetime of var starts when it is used for the first time and ends when the current session ends. A session ends when the user is inactive for 30 minutes.
Get the value of variable. An undefined var returns the text string "unknown".
name = expression
Set the variable as the value of expression. The expression is a valid BrainXML expression.
- test var
<think><var>myVar = Great!</var></think><var>myVar</var>
- Test var.
Increases the value of name by one. This works only if the name is an integer. Otherwise its value remains unchanged.
Decreases the value of name by one. This works only if the name is an integer. Otherwise its value remains unchanged.
- Different from user object, var doesn't store data persistently.
- Unless the persistent storage is necessary, it's recommended to use var instead of user object for better performance.