4 Named Rules (Subprograms)

Besides the possibility of binding rules to objects, there is also the possibility to define rules independently of an object. These rules are used like subprograms and can be called from several program places. The IDM can never call this rule by a user interaction, but always by another rule.

These so-called named rules can have up to 16 parameters. These parameters can be considered mere input values, mere output values or input/output values from the perspective of a rule. This has to be defined in the declaration of the parameters.

Instead of the keyword on these rules begin with the keyword rule to mark that it is a completely different rule type.

Syntax

rule <return type> <rule name> ( { <parameter> { , <parameter> } } )
{
  <statements>
}
parameter ::=
  <data type> <parameter name> { := <default value> } { <kind> }

<parameter> can occur up to 16 times, i.e. the rule can have up to sixteen parameters.

<return type>
<data type>

All data types that exist in the IDM are available as valid data types for rule parameters and rule return value types. For the return value type there is also the type void which marks that the rule does not return anything.

<rule name>
<parameter name>
This has to be a valid identifier.
<default value>

Default values can be defined for input parameters (input). These parameters then do not have to be specified when the rule is called.

Parameters with default values must be at the end of the parameter list!

Attention

Optional parameters are not supported by the control object and the message resource. It is currently not possible to use default values when programming an OLE Server or an OLE Client with the OLE Interface.

<kind>
  • input (default)

    only input parameter

  • output

    only output parameter

  • input output

    input as well as output parameter

Here input and output is always seen from the perspective of the rule being defined.

Example

rule integer Add (integer Arg1 input, integer Arg2 input)

This additional rule has two figures as input parameters; two parameters will be added and will have the result "sum of addition".

rule void CheckObjects ()

This defines a rule which is without parameter and which does not have any return value.