3.9 DM_CallRule

Specified rules and parameters can be called from the application with this function.

DM_Boolean DML_default DM_EXPORT DM_CallRule
(
  DM_ID ruleID,
  DM_ID objectID,
  DM_UInt argc,
  DM_Value *argv,
  DM_Value *retval,
  DM_Options options
)

Parameters

-> DM_ID ruleID

Identifies the rule to be executed.

-> DM_ID objectID

Corresponds to this in the corresponding rule, i.e. this in the rule gets the object you have specified here.

-> DM_UInt argc

Number of rule parameters.

-> DM_Value *argv

Parameter as an array of DM_Value structures. This parameter has to correspond exactly to the number given in argc. The maximum number of parameters is 16.

<- DM_Value *retval

Pointer to a DM_Value structure which is filled as the return value.

-> DM_Options options

Currently not used. Please specify with 0.

Return Value

TRUE

Rule was executed successfully.

FALSE

Rule could not be executed.

Example

Call of a rule in the dialog. The rule is defined as follows:

rule integer Callrule (integer I input)

{

  I := I + atoi(Et.content);

  Et.content := itoa(I);

  print I;

  return(I);

}

The C program here looks as this:

void DML_default DM_ENTRY CALLRULE __((DM_ID Rule))

{

  DM_Value argv;

  DM_Value retval;

 

  argv.type = DT_integer;

  argv.value.integer = 888;

  if (DM_CallRule (Rule, Rule, 1, &argv, &retval, 0))

    if (retval.type == DT_integer)

        printf(Received Value: %ld", retval.value.integer);

}