Content-type: text/html Agent Variables

Home
WebGroove is no longer supported. These docs are reference only.


Agent Variables
Agent variables are stored in hashes, also known as "associative arrays". For those out there who haven't run into the term, it's easier than it sounds. Those of you who have, skip ahead.

A hash is a collection of things, each with a name. It can be thought of as a group (hash) with one or more items (variables). You can store numeric or textual values in these variables for later use or decision-making.

The Agent variable format looks like this:

{hash:variable}

For example, {user:name} refers to the variable "name" in the hash "user", and is different from {employee:name} and {dog:name}.

To display or use the value of a variable item, simply type it where you want it to appear. So, you can have a line that says "Hello, {user:name}!" You also use the {hash:variable} syntax in Agent tags that ask for a variable, such as set, store, and mirror.

You can use most any hash or variable name in your Agent scripts. The hash is automatically created when you set the value of its first variable like:

<set {name:full} = "{name:last}, {name:first}">

Now the variable "last" in the hash called "name" would be equal to something like "Smith, Jim", depending on what was in the "last" and "first" variables. You can even use hash variables inside the perl tag as a regular variable to assign to, print, etc.

There are also a few special hashes that Agent populates for you when your script is run. The most commonly used is the cgi hash. This hash is automatically filled data from any HTML form passed to your script via CGI. So, if you have a search form on your site, your script can access the 'keyword' field by using something like {cgi:keyword}.

Also important is the sys (short for "system") hash, which stores information about your script and its surroundings.

More
Agent System Options
Agent System Variables
Form Processing (cgi)
Set Tag

See Also
Agent Scripts
Agent Tags
Clear Tag
Error Handling

Up To
Agent


WebGroove® is a registered trademark of Creativision Publishing Corporation