SET, SETI and SCRATCH

### Index Up << >>

## SET, SETI and SCRATCH

Scratch variables are maintained in the user session separate from the form variable values set on HTML forms.

Many things can be controlled with scratch variables, notable search and order processing, the `mv_click` multiple variable setting facility, and key MiniVend conditions like whether an item will be ordered on a separate line.

There are two tags which are used to access the space, `[set name]value[/set]` and `[scratch name]`.

[set variable]value[/set]
  named attributes: `[set name="variable"] value [/set]`

  Sets a scratchpad variable to value.

  Most of the mv_* variables that are used for search and order conditionals are in another namespace -- they can be set by means of hidden fields in a form.

  You can set an order profile with:

        [set checkout]
        name=required You must give us your name.
        address=required Oops! No address.
        [/set]
        <INPUT TYPE=hidden NAME=mv_order_profile VALUE="checkout">

  A search profile would be set with:

        [set substring_case]
        mv_substring_match=yes
        mv_case=yes
        [/set]
        <INPUT TYPE=hidden NAME=mv_profile VALUE="substring_case">

  To do the same as `[set foo]bar[/set]` in embedded Perl:

          [calc]$Scratch->{foo} = 'bar'; return;[/calc]

[seti variable][value something][/seti]
  Same as `[set] [/set]` except it interpolates the container text. THe above is the same as:

          [set name=variable interpolate=1][value something][/set]

[scratch name]
  Returns the contents of a scratch variable to the page. `[scratch foo]` is the same as, but faster than:

          [perl]$Scratch->{foo}[/perl]

[if scratch name op* compare*] yes [else] no [/else] [/if]
  Tests a scratch variable (see IF).

### Index Up << >>