Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

mvar

Syntax

Description

Declare a mutable variable in a SLAX script. You can initialize a mutable variable when you declare it by following the variable name with an equal sign (=) and a value.

Mutable variables differ from variables declared using the var statement in that you can change the value of a mutable variable after it is declared. To initialize or set the value of a mutable variable after you declare it, use the set statement. To append a value to the node set contained in a mutable variable, use the append statement.

Note:

Mutable variables use non-standard SLAX specific extension elements, which can affect the portability of a script.

Attributes

name

Mutable variable identifier. After declaration, you can reference the variable within expressions by using the identifier prefixed with the dollar sign ($) character.

initial-value

Initial value assigned to the mutable variable.

SLAX Example

The following example creates the mutable variable block, and initializes it. The set statement assigns a new value to the block variable, overwriting the initial value set in the declaration. In the for loop, the code iterates over each item in the specified list and appends an <item> element with two child elements, <name> and <size>, to the node set stored in the block variable.

Release Information

Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.