Skip to content

MvEVAL#


Evaluates an expression and displays the results in the browser.

Expressions must be enclosed in double quotes and curly braces, "{ expression }". Spaces between the quote and braces are not allowed (e.g. wrong " { expression }").

Syntax
<MvEVAL EXPR = "{ expression }"> 

Attributes#

Attribute Description
EXPR The expression to evaluate. Expressions can contain formulas, variables, literal values (text or numbers), functions, and operators which indicate how the other components in the expression are to be evaluated.

Examples#

In this example outputs a variables contents to the browser screen displaying the results.

Displaying a Variable
<MvASSIGN NAME="g.name" VALUE="Dana Scully">
<MvEVAL EXPR="{ g.name }"><br>

Result: Dana Scully

User defined function can be contained within a single compiled Miva Script program and called just like the built in functions. They can also be contained in separate external files.

This example calls an external user defined function contained in the file sendemail.mvc.

Using Built-in Functions
<MvEVAL EXPR="{ toupper(g.name) }"><br>

Result: DANA SCULLY
Calling External Functions
<MvEVAL EXPR="{ [ 'sendemail.mvc' ].SendEmail(to,from,cc,subject,headers,message) }">

Using Expressions in HTML Tags#

Miva Script can also evaluate expressions directly inside HTML tags. The syntax is exactly the same as the EXPR attribute.

In this example the form field for shipping is filled in with the value of the global variable g.shipping_fname:

<MvASSIGN NAME="g.shipping_fname" VALUE="Dana">

Shipping: <input type="text" name="shipping_fname" value="{ g.shipping_fname }" size="20"/>  

Result = Shipping:

In this way the expression is evaluated exactly like <MvEVAL>