;;; sec4.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1996 Universal Access Inc.
;;;  Author: Henry Minsky (hqm@ua.com) Sun Sep 15 11:05:37 1996.
<set-var title="Data Types">
<include header.mhtml>

<plain-text>
  <h2>Data Types</h2>

  The <meta-html> language deals mainly with text strings.  Most of the
  time you will be setting variables to text strings, and manipulating
  those strings. You can set the value of a variable to be any
  string. The way of entering strings in <meta-html> is very similar to
  the syntax used in regular HTML. If you want to set a variable to a
  string value, you can just type it in. If your string has spaces in
  it, then you should enclose it within double quotes:

  <example-table result>
  <set-var name="Killer Monsoon"
    address="101 East Bay Street"
    favorite-color=blue>
  <h2>Welcome, <get-var name>, to our home page!</h2>
  I see that you live at <get-var address> and that
  your favorite color is <get-var favorite-color>.
  </example-table>

  In some contexts, a string can be treated like a number.
  The <secref arithmetic operators> section of the refrence manual
  describes these in detail. The example below shows you the use of a
  numeric value in a variable.

  <example-table result>
  <set-var age=23>
  Right now you are <get-var age> years old, but after your
  next birthday, you will be <add age 1>.
  </example-table>

  <h2>Arrays</h2>
  In <meta-html> you can create arrays of elements, which then
  be accessed using the array indexing functions. Arrays are
  just strings with each element delimited by a newline character. 
  The newline can be entered using the escape sequence \n, or as
  a newline character in your page. Arrays are indexed with
  the first element starting at zero.

  Here is an example:
  <example-table result>
  <set-var colors[]="black
  brown
  red
  orange
  yellow
  green">
  <get-var colors[2]>
  </example-table>

  The above example could also have been written using the string escape
  sequence for newlines:

  <example-table result>
  <set-var colors[]="black\nbrown\nred\norange\nyellow\ngreen">
  <get-var colors[2]>
  <set-var colors[0]="chartreuse">
  <get-var colors[0]>
  </example-table>

  If you have an array (that is, a string containing newline),
  and you want to get the entire string value, you must use add
  []'s to the variable reference:

  <example-table result>
  <set-var colors[]="black\nbrown\nred\norange">
  colors is <get-var colors>,<br>
  but <i>colors[]</i> is <get-var colors[]>
  </example-table>

  When entering text which is inside double quotes, you can
  quote special characters using the backslash character ("<code>\</code>").

  <example-table result>
  <set-var name="Ray \"Boom-Boom\" Mancini">
  A 1979 graduate of Cardinal Mooney, <get-var name>
  captured national attention at 21
  when he won the World Boxing Association's
  lightweight crown in 1982.
  </example-table>

  <h2>String Manipulation</h2>

  Because strings are such a common and important data type, there are
  a number of very useful functions which operate on them. The
  reference manual section on <secref string operators> describes the
  powerful string matching, regular expression, and string
  substitution operators.

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