;;; sec2.00.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1996 Universal Access Inc.
;;;  Author: Henry Minsky (hqm@ua.com) Sun Sep 15 11:04:38 1996.
<set-var title="Assigning Values to Variables">
<include header.mhtml>

<plain-text>
  <pagelist-control-panel>
  <h2>Variables and Values</h2>

  Most programming languages provide some mechanism for <em>binding</em>
  a <em>value</em> to a <em>variable</em>. Roughly speaking, a variable
  is a receptacle for storing some information. The process of storing
  information (the value) into a receptacle (the variable) is called
  <em>binding</em> or <em>assigning</em> the value to the variable. 
  After the information has been stored, it can later be retrieved
  by <em>referencing</em> the variable.

  In meta-html, we assign a value using the <funref set-var> function,
  and we can later retrieve that value using the <funref get-var> function.
  The value of a variable can be a number, a string, or any other
  meta-html data type. We'll worry about data types later. Here, we'll
  deal with some simple strings and numbers.

  Let's look at a simple example. First, using set-var, we'll assign
  the string value <em>Hello, world!</em> to the variable <em>foo</em>. 
  Then we'll assign the numeric value <em>7</em> to the variable <em>bar</em>.

  <example-table>
  <set-var foo="Hello, world!">
  <set-var bar=7>
  </example-table>

  The set-var function stores the value to the right of the "="
  sign into the variable to the left. After it has stored the value,
  set-var returns an empty string, so there's nothing to clean up
  in your output html.

  Now that we've got a value stored in a variable, we can retrieve
  it at some later point in the program. The function <funref get-var>
  is used to get it back:

  <example-table>
  <get-var foo>
  <get-var bar>
  </example-table>

  This returns something like the following:

  <code>
  Hello, world!<br>
  7
  </code>

  <pagelist-control-panel>
</plain-text>
<include footer.mhtml>
