3.3. set, seti, tmp, tmpn 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 four tags that are used to set the scratch space: [set variable] value [/set], [seti variable] value [/seti], [tmp variable] value [/tmp], [tmpn variable] value [/tmpn] and and two tags for reading scratch space: [scratch variable] and [scratchd variable].
[set 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 [/seti]
-
The same as [set] except it interpolates the container text. The above is the same as:
[set name=variable interpolate=1] [value something] [/set]
[tmp variable] value [/tmp]
-
The same as [seti] except it does not persist.
[tmpn variable] value [/tmpn]
-
The same as [set] except it does not persist.
[scratch variable]
-
Returns the contents of a scratch variable to the page. [scratch foo] is the same as, but faster than:
[perl] $Scratch->{foo} [/perl]
[scratchd variable]
-
The same as [scratch variable] except it deletes the value after returning it. 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 documentation for more information.