ContentsWeb Page DesignSetting New Variables
Previous: Using Variables | Next: Using Java Commands

Setting New Variables

There are two ways that a web page designer can create new WELD variables:

Setting variables

The set command accepts either one or two parameters.  The most frequent use is to provide a name and a value.  Occasionally, however, the value is omitted in order to fill the results of several commands.  In either case, the result of set will be the value of that variable.

What this means is that you can take a fragment of HTML and set it to a variable, then reuse it where ever you need.

Grouping multiple words to be a single parameter

The syntax of set requires that the value will appear to be a single parameter.  This is done by grouping words, placing either brace ({ and }) characters around them, or by using double-quote (" and").  The difference between these two forms of groupings is that braces prevents any variable substitution or command execution, whereas double-quotes permits this behavior.

Example 1:

[set jumpIcon {<a href="/support.html"><img src="jmp.gif">Get help</a>}]

The braces group the different words (delimited by space, tab, or newlines) to make the set command see this grouping as a single parameter.  Now just place $jumpIcon anywhere that this icon and hyperlink are needed.

Building on this, it may be that the URL of the support page and the image to be used are defined by other variables ($supportPage and $jumpImage).  In order to group these into the second parameter, we need to use double-quotes instead of braces.

Example 2:

[set jumpIcon "<a href=$supportPage><img src=$jumpImage>Get help</a>"]

 If braces were used, the variables would not be substituted.

Back-slash quoting

Sometimes you may find it necessary to use double-quotes within a grouping where you still want to allow substitution.  This is accomplished by using the back-slash character (\) before the double-quotes to defeat what would have been interpreted as a close-quote.

Example 3:

[set jumpIcon "<a href=\"$supportPage\"><img src=\"$jumpImage\">Get help</a>"]

In the case where the file names may contain spaces, the web browser will need the hard quotes to keep the HTML parameters together.  If the \" syntax seems awkward to you, feel free to set and use a variable instead (e.g. [set dQuote {"}]), which would make the example look like this:

[set jumpIcon "<a href=$dQuote$supportPage$dQuote><img src=$dQuote$jumpImage$dQuote>Get help</a>"]

 


ContentsWeb Page DesignSetting New Variables
Previous: Using Variables | Next: Using Java Commands

Modified: Tue Apr 18 14:34:15 EDT 2000