3.3. set, seti, scratch and scratchd
Scratch variables are maintained in the user session, which is separate from the form variable values set on HTML forms. Many things can be controlled with scratch variables, particularly search and order processing, the mv_click multiple variable setting facility, and key Interchange conditions session URL display.
There are three tags that are used to set the space, [set name]value[/set], [seti name]value[/seti], [tmp name]value[/tmp], and two variations (or shortcuts).
[set variable]value[/set]
-
named attributes: [set name="variable"] value [/set]
Sets a scratchpad variable to a value.
Most of the mv_* variables that are used for search and order conditionals are in another namespace. They can be set through hidden fields in a form.
An order profile would be set with:
[set checkout] name=required Please enter your name. address=required No address entered. [/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]
-
The same as [set] [/set], except it interpolates the container text. The above is the same as:
[set name=variable interpolate=1][value something][/set]
[tmp name]value[/tmp]
-
The same as [seti] but it does not persist.
[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]
[scratchd]
-
The same as [scratch name], except it deletes the value. Same as [scratch foo][set foo][/set].
[if scratch name op* compare*] yes [else] no [/else] [/if]
-
Tests a scratch variable. See the IF tag for more information.