In general terms, a variable is "that which is variable; that which varies, or is subject to change".

In computer terms, variables have a name most of the time, so that you can refer to them. For example, variable $amount might have a value of 10, and that value may change over time.

Basically, all programs work with (a lot of) variables, be it to define their behavior or store intermediate results.

In Interchange, there are many kinds of variables. We have:

Read the respective glossary entries. This entry only deals with global and catalog variables.

Global and catalog variables are basic ways of storing variable information in Interchange. They are basically the same, but some of the definitions only make sense at global (Interchange server) level, and some only make sense at "local" (individual catalog) level. There's also a fallback mechanism available that can query the global setting if its instance at catalog level is not set.

Of those variables, we further (informally) distinguish between "core", "distribution" and "standard" variables. Core variables are being honored by common, underlying Interchange code; distribution variables are honored in our out of the box configurations, and standard variables are being honored in our standard demo catalog that we ship along with Interchange.

Look up the Variable configuration directive for instructions on setting variable values. Look up the [var] tag for basic instructions on getting variable values.

Global and catalog variables are not normally modified dynamically (they keep their value as set in interchange.cfg or catalog.cfg). However, they can be manipulated at runtime, in which case you most probably want to do it before Interchange puts a requested page into processing. This is best done in an Autoload routine.


By the way, an Autoload routine is what gives your catalog unlimited flexibility. It made my head spin in disbelief when I first saw some of the Autoload tricks, and it continues to amuse me to this day. If you want to take a quick break from problem at hand, see configuration glossary entry for an explanation of what happens with configuration directives on each page request, and Autoload reference page for Autoload-specific discussion and examples.

When accessing variables, we distinguish between three access types: from ITL code, from embedded Perl code, and from GlobalSubs or tags.

Here's a complete list of ways to access global or catalog variables:


Access syntaxPlace of definition
@_VARNAME_@catalog.cfg, with fallback to interchange.cfg
[var VARNAME]catalog.cfg
[var VARNAME 1]interchange.cfg
[var VARNAME 2]catalog.cfg, with fallback to interchange.cfg

In embedded Perl:

Access syntaxPlace of definition
$Tag->var('VARNAME', 1)interchange.cfg
$Tag->var('VARNAME', 2)catalog.cfg, with fallback to interchange.cfg

In GlobalSub code or usertags:

Access syntaxPlace of definition
$Tag->var('VARNAME', 1)interchange.cfg
$Tag->var('VARNAME', 2)catalog.cfg, with fallback to interchange.cfg
$Global::Variable->{VARNAME}interchange.cfg, and only within GlobalSub code

DocBook! Interchange!