var

  • Output field : Gets or sets a user-specific temporary variable.
<var>name</var>
<var>name = expression</var>
<var>name ++</var>
<var>name --</var>
  • Condition or JS field : Gets or sets a user-specific temporary variable.
var.name
var.name = expression;

Description

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.

Parameters

name

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.

Examples

Example 1

    • test var
    • <think><var>myVar = Great!</var></think><var>myVar</var>
    • Test var.
    • Great!

name ++

Increases the value of name by one. This works only if the name is an integer. Otherwise its value remains unchanged.

name --

Decreases the value of name by one. This works only if the name is an integer. Otherwise its value remains unchanged.

Notes

  • 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.