Section Intro: Variables
Meta-HTML provides a simple mechanism for the storage and retrieval of variables during a single (possibly recursive) processing pass. In addition to this, functions are provided which test the value of a variable, and conditionally execute other code based upon the result.
There is also a mechanism to group a set of variables using Packages.
Variable Types and Information
There are internal functions in Meta-HTML which create binary
variables. Such variables cannot be used in the ordinary way, since
the data contained within them may not retain integrity once printed
out and read back in. You can check to see what the type of a
particular variable is with the
Many variables are predefined by Meta-HTML, and made available to the page writer. The Page Variables section of this manual documents those variables fully, while the Server Variables section contains more information on variables which control, or were specifically created by, the web server.
Concatenate the contents of COLLECTOR and the supplied BINARY-VARs into a single binary variable, and store the results back in COLLECTOR.
Decode STRING into PACKAGE.
If PACKAGE is not specified the current package is used.
STRING is a string that might have appeared in
PACKAGE is the name of a package to bind the variables in. So, given the above example as the text in a variable called STRING, here is what you get:
<set-var string="FOO=bar&STRING=this+is+a+string%2C+other+chars"> <cgi-decode <get-var string> mypack> <get-var mypack::string>produces:
this is a string, other chars
A CGI readable string is created from the names of the VARs given,
and the associated values of those variables. For example, if the
Given the optional keyword argument of PRESERVE-CASE=TRUE,
Finally, the keyword flag STRIP=TRUE, when present, says to
strip off the package name of each variable before placing it in an
assignment statement (also see
<set-var FOO::BAR=value> <cgi-encode Foo::Bar preserve-case=true strip=true>produces:
Coerces VARNAME's data to have the type specified by the argument to TYPE. You can convert a binary object to a string object, and vice-versa.
A binary variable might be created as the result of a call to
<with-open-stream s /tmp/file mode=read> <stream-get-contents s foo> </with-open-stream> <p> <coerce-var foo type=string> <subst-in-string <get-var-once foo> "Hello" "Goodbye">
Return the length of the contents of VAR. If VAR is an array or string, returns the number of elements in the array. If VAR is a binary variable, returns the amount of data stored within. If VAR is a function, returns the empty string.
<dir::read-file /etc/passwd myvar> ==> true <content-length myvar> ==> 864
Convert the contents of the binary variable named by VARNAME to be a sequence of hex characters.
Copies the variable FROM-VAR to each of the named TO-VARs.
Each TO-VAR becomes the repository of a copy of the information already stored under FROM-VAR. This is a true copy; not an alias to the original variable.
<set-var foo=bar> <get-var foo> ==> bar <get-var new> ==> <copy-var foo new> ==> <get-var new> ==> bar <p> <copy-var *meta-html*::get-var *meta-html*::foo> <foo new> ==> bar
Subtract AMOUNT (default 1) from the contents of the variable named by VARNAME.
<set-var foo=1> <get-var foo> ==> 1 <decrement foo> <get-var foo> ==> 0
DEFault the value of the VARiable named by NAME to VALUE.
<define-tag defvar var &optional val> <if <not <get-var <get-var-once var>>> <set-var <get-var-once var>=<get-var-once val>>> </define-tag>
Synonym for <get-var-eval>
The values are returned in the order in which the NAMEs appear.
<set-var foo=Var-1 bar=Var-2> <get-var-eval foo>, <get-var bar>produces:
When multiple NAMEs are given:
<set-var foo=Var-1 bar=Var-2> <get-var foo bar foo>produces:
Returns the current value of the variables named by the NAMEs given. The interpreter pointer is then moved to after the returned data, thus preventing further interpretation of the data.
<set-var bar=HELLO> <set-var-verbatim foo=<get-var bar>> <get-var-once foo> ==> <get-var bar>but...
<get-var foo> ==> HELLO
Convert the string of hexadecimal digits passed in STRING to their binary contents, placing the result in VARNAME.
Add AMOUNT (default 1) to the contents of the variable named by VARNAME.
<set-var foo=1> <get-var foo> ==> 1 <increment foo> <get-var foo> ==> 2
Gives the variable NAME the value of VALUE for the current processing run. Any number of name/value pairs may be given, and whitespace is not significant. Where =VALUE is omitted, the value is the empty string.
<set-var foo=bar bar=baz> <get-var foo> ==> bar <get-var bar> ==> baz <get-var <get-var foo>> ==> baz
For each NAME specified, if that name is not already assigned a
Once NAME has had a value assigned to it with
A useful construct for setting various site specific variables in your
Gives the variable NAME the value of VALUE for the
current processing run. The difference between
<set-var-verbatim foo=<get-var bar>> <get-var-once foo>produces:
Returns information about the symbol SYMBOL.
The information is returned in an alist containing:
The size value is zero for all other variable types.
Make NAMEs be non-existent in the page environment.
This is different than
<set-var foo=""> <var-exists foo> ==> true <get-var foo> ==> <unset-var foo> <var-exists foo> ==>
<set-var foo=1 bar> <var-exists foo> ==> true <var-exists bar> ==> true <get-var bar> ==> <unset-var foo> <var-exists foo> ==>
The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox
Found a bug? Send mail to firstname.lastname@example.org