Attributes . . Usage . . Related Topics . . Tag Index . . Home


<?MIVAR><?/MIVAR>

The MIVAR tag enables you to assign and display variables in an HTML page. Use variables with AppPage tags to dynamically generate and format the results of SQL statements or to pass values between application code and the AppPage.

Attributes

NAME Specifies the name of the variable specified by the text between the begin and end MIVAR tags. If NAME is not specified, the text between the begin and end MIVAR tags is output. Variables within the text are expanded.
DEFAULT Specifies the optional default value for any unassigned variables between the begin and end MIVAR tags. This value can be another variable.
COND A variable or variable expression that evaluates to FALSE (0) or TRUE (nonzero). Conditions are evaluated from left to right. The tag is enabled only if this condition evaluates to TRUE. For an example, see the MIBLOCK tag.
ERR Specifies how an error should be processed. Because multiple errors can occur on an AppPage, use the ERR attribute to link the error processing to a particular MIERROR tag. For more information on the ERR attribute, see the MIERROR tag.

Usage

Use the NAME attribute to assign the value of the text between the begin and end MIVAR tags to that variable name. Use the DEFAULT attribute to specify a default value for any unassigned variables between the begin and end MIVAR tags.

Using the NAME and DEFAULT Attributes

The following example demonstrates the assignment of variables:

<?MIVAR NAME=$TITLE>Entrepreneur<?/MIVAR>
<?MIVAR NAME=$SALUTATION> Dear $TITLE: <?/MIVAR>
<?MIVAR>$SALUTATION <BR> You are a sweepstakes winner!<?/MIVAR>

When you do not specify the NAME attribute, the text between the tags is output. Variables between the tags are expanded. As a result of the preceding tags, the following HTML is generated:

Dear Entrepreneur: <BR> You are a sweepstakes winner!

The following example demonstrates the use of default values:

<?MIVAR NAME=$TITLE DEFAULT='Sir or Madam'> $INPUT_TITLE <?/MIVAR>
<?MIVAR> Dear $TITLE: <BR> You are a sweepstakes winner! <?/MIVAR>

If the INPUT_TITLE variable is assigned elsewhere--for example, in a previous MIVAR tag or in an HTML form--that value overrides the DEFAULT value. If the INPUT_TITLE variable is unassigned, the following HTML is generated:

Dear Sir or Madam: <BR> You are a sweepstakes winner!

Within the NAME attribute assignment (NAME=$varName), the $ in front of the variable name is optional. In all other cases, you must precede the variable name with $.

Related Topics

For information about how to escape special characters (", { , }, and $) so that they are interpreted literally, see Special Characters in AppPage Tags.

For more information about variables, see Using Variables and Variable Expressions in AppPages.


Top of Page . . Attributes . . Usage . . Tag Index . . Home