Home Page

Table Command Replace Command

Contents

 Introduction
 Hip Commands
 Using Hip
 Messages
 Examples
 Limits
 Warnings
 Support
 Future

Variable Substitutions

HIP supports arbitrary text substitution for named variables. A variable is defined in one of two ways:

Once defined, a variable is reference by including a phrase like this in the document where the value is to appear:

&&name;

(that's 2 &'s a name and a semicolon, exactly. Think of it as an extension to the HTML extended character mechanism.)

HIP will attempt to perform a substitution whenever it encounters the &&name; construct, and if the 'name' has been defined, the phrase 'value' is substituted. Of course, name and value in this discussion represent arbitrary stings, not the literals 'name' and 'value'.

Indirect references to variable values are also possible using the following form:

&&@name;

This form will look up the value for 'name' and then use that value as a variable name to look up the substitution value. For example, if a table file contains the following lines:

    direct=value
    indirect=direct
then the substitution value for '&&@indirect;' will be 'value'.

Keep the following restrictions in mind when using variables.

  • Name is not case sensitive and must be less than 36 characters long.
  • In the case of duplicate names, the most recently assigned value will be used
  • Do not include spaces between the 'name' and '=' and 'value' parts, or in the name portion.
  • Malformed phrases where 'name=value' pairs should appear are ignored.
  • If the phrase includes spaces, surround the whole 'name=value' pair with quotes (nor required in table files.)
  • Substitution is not normally performed in the top level file, although echo commands and build mode can circumvent this limitation.
  • Certain variables are pre-defined when HIP is invoked.

Variable Scope

Variables defined with these mechanisms have a limited scope. Each level of include file nesting establishes a new set of variables which are discarded when the file ends. In addition to the variables defined within a given level, all definitions from any parent levels are also available. In the case of a definition in a 'name=value' clause in an include or replace command, the variable definition is available within the included file and to any files included from within it. In the case of a table command, the variables are available within the file which contained the table command and any files subsequently included within it. If a variable is redefined in subsequently included files, the redefinition follows these same scope rules, and will revert to its original value when exiting that scope. If a variable is defined more than once within the same level, only the most recent definition is used.


Home | ttf.library | Movies | Amiga | PGP | E-mail Me