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.
![]() | Note |
---|---|
By the way, an |
When accessing variables, we distinguish between three access types:
from ITL code, from embedded Perl code, and from GlobalSub
s or
tags.
Here's a complete list of ways to access global or catalog variables:
In ITL:
Access syntax | Place of definition |
---|---|
__VARNAME __ | catalog.cfg |
@_VARNAME _@ | catalog.cfg , with fallback to interchange.cfg |
@@VARNAME @@ | 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 syntax | Place of definition |
---|---|
$Variable->{VARNAME } | catalog.cfg |
$Tag->var('VARNAME ') | catalog.cfg |
$Tag->var('VARNAME ', 1) | interchange.cfg |
$Tag->var('VARNAME ', 2) | catalog.cfg , with fallback to interchange.cfg |
In GlobalSub code or usertags:
Access syntax | Place of definition |
---|---|
$::Variable->{VARNAME } | catalog.cfg |
$Tag->var('VARNAME ') | catalog.cfg |
$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 |