26. variable
| Chapter 2. Predefined commands |

## 26. variable

    variable(name, value)

Declares a local variable having specified name in a `macro`. Initializes local variable to specified value. Parameter `name` is a string representing an XML qualified name.

It's an error to use `variable()` outside a `macro`.

Example:

    set-variable("v1", 0);

    macro m1() {
        (: Local to macro m1. Shadows global variable v1. :)
        variable("v1", 1000);

        set-variable("v1", $v1 + 500);

        if ($v1 != 1500) {
            error("FAILED");
        }
    }

    if ($v1 != 0) {
        error("FAILED");
    }

25. unwrap-element |  | 27. warning