scratch

When Interchange creates a user session, it also initializes the scratch space (also referred to as the scratchpad) to hold various variables which are valid throughout the session.

By default, the scratch space is created empty. You can define default scratch variables and their values using ScratchDefault.

Once defined, a scratch variable will exist either until it is explicitly deleted (most probably using [scratchd] tag) or the session ends. The exception are so-called "temp" variables, which are normal scratch variables (they live in the scratch space), but are automatically deleted when page processing ends. You can use them for saving intermediate results that you calculate and display, and then want Interchange to automatically forget.

The catalog programmer has complete control over the scratch variables. The following tags manipulate the scratch space: [set], [seti], [tmp], [tmpn], [scratch] and [scratchd].

Here's a complete list of ways to set scratch variables.

In ITL:

Set syntaxAttributes
[set VARNAME]VALUE[/set]ITL code in value body is not interpolated
[seti VARNAME]VALUE[/seti]ITL code in value body is interpolated
[tmp VARNAME]VALUE[/tmp]ITL code in value body is interpolated, variable is temporary
[tmpn VARNAME]VALUE[/tmpn]ITL code in value body is not interpolated, variable is temporary

In embedded Perl:

Set syntaxAttributes
$Scratch->{VARNAME} = 'VALUE';Set value
$Tag->tmp('VARNAME');Mark scratch variable as temporary, must set a value afterwards
$Tag->tmp('VARNAME', 'VALUE');Mark scratch variable as temporary and set value at the same time

In GlobalSub code or usertags:

Set syntaxAttributes
$::Scratch->{VARNAME} = 'VALUE';Set value

Here's a complete list of ways to get scratch variables.

In ITL:

Get syntaxAttributes
[scratch VARNAME]Display value
[scratchd VARNAME]Display value, delete scratch variable

In embedded Perl:

Get syntaxAttributes
$Scratch->{VARNAME};Get value
$Session->{scratch}{VARNAME};Equivalent

In GlobalSub code or usertags:

Get syntaxAttributes
$::Scratch->{VARNAME};Get value
$::Session->{scratch}{VARNAME};Equivalent

One other predefined use for scratch variables is to hold form processing code (code that is executed on users' form submission). See the [button] tag for examples.

DocBook! Interchange!