Miva Merchant: E-commerce Solutions to Grow Online
spacer gif

Chapter 2

Introduction

A Miva Merchant module is a set of functions. Each function provides Miva Merchant with the data required to perform a specific task. There are 13 module types and each type requires specific functions to be in the module.

Module Functions

Functions that are used within Miva Merchant have the following syntax.

<MvFUNCTION NAME="modulefunc"
PARAMETERS="var1,var2,..."
STANDARDOUTPUTLEVEL="html,text"
ERROROUTPUTLEVEL="syntax,expression,runtime">
...code...

<MvFUNCRETURN VALUE="{expression}">
...code...
</MvFUNCTION>

where:
Function
Description
<MvFUNCTION>
Starts the function.
NAME
Defines the name of the functions. Miva Merchant uses the name to call the function.
PARAMETERS
Parameters can optionally be defined with the attribute. Parameters are variables whose scope is the body of the function, that is, they are not meaningful anywhere outside the function. When the function is called, the parameters are automatically assigned the values of the arguments that are specified when the function was called.
<MvFUNCTIONRETURN VALUE >
Optionally terminates the function with the return value specified with "expression. "
STANDARDOUTPUTLEVEL
html - HTML tags are passed to the browser.
text - text is passed to the browser.
text, html or html, text - both text and HTML tags are passed to the browser (same as the default)
null string - neither text nor HTML tags will be passed to the browser.
compresswhitespace - when enabled, causes the Miva Engine to eliminate any extra whitespace in the output of Miva Script code.
ERROROUTPUTLEVEL
Enables you to specify which kinds of errors Miva Merchant will report. By default (that is, if you don't have an explicit setting for ERROROUTPUTLEVEL) all three types of errors are reported.
The possible values are any combination of syntax, expression, and runtime. The list of values are comma-separated.
</MvFUNCTION>
Ends the function.

For further information on function structure and use, refer to the Miva Script Reference Manual.

Function Return Value

There are two types of return values generated by the module functions.
Value
Description
string value
These values are inserted into the function by the developer. An example of this type is Module_Type which returns the string value that is assigned to <MvFUNCTIONRETURN VALUE = "(value)">.
Boolean
Most functions simply return a Boolean value of 1 or 0. One indicates the function has completed successfully. When a zero is returned, an error code or error message must also be returned.

Requirement for Functions in the Module

There are certain functions that must be present in every module. This manual defines the functions that must be present in each type of module. Required functions that are unused return a Boolean yes (1). The structure shown below is all that is required:

<MvFUNCTION NAME = "(function name)" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">

<MvASSIGN NAME = "l.ok" VALUE = 1>

Error Messages

The developer is responsible for creating and returning error messages for errors that occur during the processing of the function.

Errors returned by Miva Empresa or the operating system are displayed on the terminal screen.

Examples

Miva Merchant comes with a group of modules. These modules are stored in subdirectory below the modules directory which is in the Merchant2 directory. Refer to these modules for examples of how the functions are used within a module. Review more than one module of each type, because functions can be used in different ways and you may not get the full functionality by just looking at one example.