MFP language function, return and endf statements:
Function statement in MFP is a start of a function. It should be used as
Function name(parameter1, parameter2, parameter3, ...)
. Note that "..." here means there are various number of parameters following parameters 1 to 3. If there is no optional parameter, no "..." should be used. For example:
Function abcd(para1, para2, para3, para4)
is a function named abcd with four parameters, while
Function abcdx(para1, para2, para3, para4, ...)
is a function with >= 4 parameters. The number of optional parameters (excluding para1 to para4) is stored in a system variable named opt_argc. The first to fourth parameters have defined name which are para1, para2, para3 and para4 respectively. The first optional parameter's value is stored in opt_argv[0] where opt_argv is a system array variable. Similarly, the second optional parameter's value is opt_argv[1], the third is opt_argv[2], etc.
A function statement can return a value or return nothing. However, user needs not to clare the return variable name in function statement. MFP can automatically process the return.
Return statement in MFP is used to exit from a function or a call ... endcall block and return a value (which can be any data type) to caller if needed. Please note that if it is a call ... endcall block, the returned value will be transferred from server to client. For example:
Return "Hello word" // return a string "Hello word"
or
Return // return nothing
.
Endf statement is the end of function block. It is simple and does not take any parameter.