Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 3 Tools : $CALLRULE

$CALLRULE
Invokes a procedural rule. (C)
Invocation
CALL $CALLRULE(rulecall)
 
A character string of syntax V (variable-length character string) or UN (Unicode) containing the name of the rule to be invoked, and, if the rule takes one or more arguments, a left parenthesis, a list of the comma-separated arguments, and a right parenthesis.
Usage Notes
You can pass a NULL value to the rule by omitting  an actual value from the list of parameters in the position of the parameter to be passed the NULL. For example, in the sample rule below, to call ADDC without a value for B, you would use:
CALL $CALLRULE('ADDC(' || A || ',)');
If the rule to be invoked does not exist in a library in the current search order of the transaction, an untrappable error occurs. You can use the $RULE_EXISTS shareable tool to test for the existence of a rule before trying to invoke it.

Exceptions
 
Raised if rulecall is not a string conforming to the format described above.
Example
This rule receives a request to process two numbers by adding them together or subtracting them from each other. It then calls the appropriate user-written rule to do that processing. If one of the rules does not exist, the terminal displays an end message.

 
RULE EDITOR ===> SCROLL: P
ARITHC(A, OPERATION, B);
_ LOCAL C;
_ -------------------------------------------------------------------------
_ $RULE_EXISTS('ADDC') = 'N'; ¦ Y N N N N
_ $RULE_EXISTS('SUBTRACTC') = 'N'; ¦ Y N N N
_ OPERATION = '+'; ¦ Y N N
_ OPERATION = '-'; ¦ Y N
_ ------------------------------------------------------------+------------
_ SIGNAL NORULE; ¦ 1 1
_ CALL $CALLRULE('ADDC(' || A || ' , ' || B ||')'); ¦ 1
_ CALL $CALLRULE('SUBTRACTC(' || A || ' , ' || B ||')'); ¦ 1
_ CALL ENDMSG('THE RESULT OF ' || A || OPERATION || B || ¦ 2 2
_ ' IS ' || C); ¦
_ -------------------------------------------------------------------------
_ ON NORULE :
_ CALL ENDMSG('RULE NOT FOUND');
_ ON EXECUTEFAIL :
_ CALL ENDMSG('CHECK SYNTAX IN RULE');
 
 
 
PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
This is one of the rules ARITHC calls:

 
RULE EDITOR ===> SCROLL: P
ADDC(A, B);
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ C = A + B; ¦ 1
_ ---------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
The output message from ARITHC is similar to:
THE RESULT OF 7+2 IS 9

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved