Skip to content

MvDO#


<MvDO> works in two somewhat different ways, depending on whether NAME and VALUE are present. If they are specified, the function is the only code in the external file that gets executed. ALL other MivaScript and HTML code is ignored. This allows you to create libraries of functions stored in external compiled files.

If NAME and VALUE are omitted, everything in the external file is executed; however, any script contained within <MvFUNCTION> blocks is ignored. Starting at the beginning of the file, the results of all <MvASSIGN> tags are available to the calling program. All system and global variables, and all open databases, are available to the code in the external file. For example, a file could contain initialization script, setting global variables and opening databases.

Syntax
<MvDO FILE = "string: {  expression } | literal"
      NAME = "string: {  expression } | literal"
      VALUE = "{ function_name( paramiters ) }"> 

Attributes#

Attribute Description
FILE Path and name of the compiled file. If relative, it is relative to the current file.
NAME (Optional) When omitted, the file is processed as if included in the current document. If specified, it is the name assigned to the variable which will contain the results. Normally a literal, but can also contain an expression that results in a variable name.
VALUE (Optional) The expression that calls the external function. Syntax is the same as for any other MivaScript function.

Note

If the required attribute FILE is missing, a value (error message) for the variable mvdo_error is set, and the script continues processing.

Examples#

Including External Files
<MvDO FILE="/settings.mvc">
Calling External Functions
<MvDO FILE="myemail.mvc" NAME="g.ok" VALUE="{ SendEmail( to, from, cc, subject, headers, message) }">

Specify the file and call functions using square brackets:

Alternate Syntax
<MvASSIGN NAME="g.result"
          VALUE="{ [ g.module_email ].SendEmail(to,from,cc,subject,headers,message) }">

<MvEVAL VALUE="{ [ g.module_email ].SendEmail(to,from,cc,subject,headers,message) }">

<MvIF EXPR="{ NOT [ g.module_email ].SendEmail(to,from,cc,subject,headers,message) }">
    Your email COULD NOT be sent.
<MvELSE>
    Your message was sent.
</MvIF>