|
Used to call an function declared with
<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 Miva Script and HTML code is ignored.
This allows you to create librarys of functions stored in external compiled files. Attributes
Note: If the required attribute FILE is missing, a value (error message) for the variable mvdo_error is set, and the script continues processing. ExamplesIncluding external files:<MvDO> tags can be nested in the sense that the file filename specified by the <MvDO> can itself contain an <MvDO>. The filename path specified by the "nested" <MvDO> is relative to the location of the file containing that <MvDO> (unless it starts with a forward slash, it which case it is relative to the Miva Script document root directory). Note: There is a limit on the number of nested MvDO calls at run-time. This limit is fixed at 23 for Miva Merchant Mia; the default limit for Miva Merchant Empresa is 23 by default, but this can be changed by the server administrator via the maxfunctiondepth setting in the global configuration file. Miva does not interpret server-side includes (SSI). In older (pre-compiler) versions of Miva Script, MvDO could be used to load .html documents. As show below, this no longer works. However, the file_read() function can be used for that purpose. <MvDO> can be used to directly call and execute another compiled .mvc program from within the current document. For example: Example:<MvDO FILE="/settings.mvc"> Calling external functions:Libraries of common functions can be compiled to separate files and called by your programs. In this example a file named myemail.mvc contains a function called SendEmail() used to send an email message. The file could contain many other user functions for validating email address or receiving email. Example:<MvDO FILE="myemail.mvc" NAME="g.ok" VALUE="{ SendEmail( to, from, cc, subject, headers, message) }"> An alternate syntax exists for calling external function without using <MvDO> where the file name can be specified using square brackets (e.g. [ 'filenam.mvc' ].function_name() ) In this example three variations on this method are shown. Example:<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>
|