403 users using DBSP now!
home -> documentation -> environment guide -> Evaluating expressions: EXPVAL tag


Sometimes is necessary to make certain calculations and place the result at some point in the page. Even though you can use the SETCOOKIE element for this purpose, you don't have the necessity to store the value in memory; you just want to present the result. This exactly is the function of the EXPVAL Tag.

The EXPVAL tag

This tag evaluates the expression contained in the EXPRESSION property and inserts the resulting value instead.

Consider the next example:

<p>TAX: <#EXPVAL EXPRESSION="AMOUNT*0.10"/></p>

The code above will evaluate the expression contained in the EXPRESSION property and replace the tag with the obtained result. The final document will contain something like this:

<p>TAX: 200</p>

Formatting the result

If the result is numeric, you could give some format in order to improve the presentation of the data. The syntax of the FORMAT property is listed below:

<#... FORMAT="format:precision:digits"/>

format is the format structure to use in order to present the value. It could have these values: GENERAL, EXPONENT, FIXED, MONEY, NUMBER or PERCENT. If you want a detailed explanation of each format, press here.

precision specifies the precision of the given value. It should be from 7 to 18.

digits specify the number of digits to present after the decimal point.



Examples

Example 1. Runtime calculations.

This example shows how to calculate values on the fly using the EXPVAL tag.

Source code
Test example

Previous | Next