Local Variables

Sometimes you may want to hold onto some value for use later on in the same template. You can do this by storing the value in a local variable. Here is a simple example where a sum is stored in a variable and later printed out:

Sum ()
TITLE "Lucky"
  WITH= variable x
        value 2 + 5
   TEXT x
The WITH= operator is another one that can contain expressions. Within any of those expressions, the variable given as the variable argument will refer to the value given as the value argument. So when we get to the expression

it will print 7.

A variable can have anything as its value, even an image. Here is a template that solves a common problem: how to make page elements the same width:

Lineup ()
TITLE "Underscored Greeting"
  WITH= variable im
        value RENDER text "Hello"
                     font-size 60
      IMAGE source im
      HRULE width WIDTH im
It generates a page containing a centered image of the word "Hello" rendered in 60-point Helvetica, and beneath it a horizontal rule exactly the same width.

There are three new operators here. CENTER causes everything generated by the expressions it contains to be centered; HRULE generates a horizontal rule; and WIDTH returns the width of its argument.

Because we put the image in the local variable im instead of making the RENDER expression simply be the source argument of IMAGE, we can still find the width of the image after it has been inserted in the page.

Sales: 1-888-4-VIAWEB or
Support: 1-617-876-9678 or