Welcome
 Revisions
 Downloads »
 FAQ
 Tutorials »
 Reference »
  Contents
  Commands »
   Variables
   Selection
   Files
   Procedures
   Automation
   Expansions
   Cookies
   Testing
  Strings

Hitop Reference: Variables

Setting

<@SET NAME="varname" ( [VALUE="value"] | [EXPR="expression"] [SCOPE="(LOCAL|PARENT|GLOBAL)"] [DEFAULT]>

Sets the named variable to the value (or result of evaliating the expression) specified (or marks it as "existing" if no value or expression is given). The default scope is local&nsbp;- that is from the current procedure downwards. Parent scope sets it only in the calling environment, while global sets it in all parent scopes.

If DEFAULT is given, the variable will only be set if it isn't already - effectively it allows you to give a default value for one not already specified.

Getting

<@GET ( NAME="varname" [FORMAT="commands"] | EXPR="expression" ) >

Retrieves the string stored in the named variable. Variable contents can be retrieved for use in markup by using the form ${varname}. Variable names may be nested ${${var1}${var2}} or used as markup name <${var1}>. Attempting to retrieve the value of an undefined variable will give an error. This can be guarded by using <@IF> without a VALUE.

The optional string processing commands can be appended to the variable name with a colon in either inline expansion or using <@GET>, or specified in FORMAT for <@GET>. String literals to be formatted may also be specified. For example:

<@SET NAME="CAT" VALUE="aardvark">
<@GET NAME="CAT" FORMAT="UPCASE()">
<@GET NAME="CAT:UPCASE()">
<@GET NAME="'aardvark':UPCASE()">
All give AARDVARK.

The following variables are predefined but may be overloaded:
DATE the date the file is being built in the format YYYY-MM-DD
DATEYEAR the year the file is being built in the format YYYY
DATEMONTH the month the file is being built in the format MM
DATEDAY the day the file is being built in the format DD
TIME the time the file is being built in the format HH:MM:SS
TIMEHOUR the hour the file is being built in the format HH
TIMEMINUTE the minute the file is being built in the format MM
TIMESECOND the second the file is being built in hte format SS
FILE the name of the file being built including its path relative to the base of the site
RELPATH the path of the base of the site relative to the file being built. Consists of multiple "../"

If EXPR is given, it simply returns the value of the mathematical expression given.

Unsetting

<@UNSET NAME="varname" [SCOPE="(LOCAL|PARENT|GLOBAL)"]>

@UNSET does the same as @SET but removes the value given to a named variable.

Last updated 2001-06-16