Defining A Method
Finally we can now get to the heart of the matter and tell you how to create a method. Let us start with another example:
BOOLEAN
METHOD __FieldIsBetween__
/* Checks a field value to see if it falls between two other values. */
CODE
bOk = ((ai64Field[fldParam3] >= i64Param1)
&& (ai64Field[fldParam3] <= i64Param2));
ENDCODE
PARAM "Low value" int64
PARAM "High value" int64
PARAM "Which field" field
The method starts with a keyword that states its type, BOOLEAN in this case. Then comes the keyword METHOD followed by the method's name and a comment describing what the method does. The actual C++ code of the method is delimited by the keywords CODE and ENDCODE. Finally comes the list of parameters. Each parameter is defined by a statement of the form:
PARAM "<description>" <type> [= <default value>]
<description> text that describes the parameter.
<type> is one of the parameter types listed in the table in the following section. [=<default value>] allows you to make the parameter optional by specifying the default value to use if the decoder writer doesn't include one. A good example of this is the Size method Fixed, which allows the Units parameter to be optional by specifying a default of "Bytes".
A method may have up to 15 parameters. Only input parameters are allowed.