Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

8.4.9 *ANDIF and *ORIF Logical Operators

RDMLX supports *AND and *OR logical operators. The following code fragment illustrates the syntax of these operators:

     ConditionalExpression1 *OR  ConditionalExpression2
ConditionalExpression1 *AND ConditionalExpression2

...

Sometimes you may want to stop the second conditional expression based on the result of the first conditional expression. Referred to as short-circuiting, the following example illustrates the coding style that has previously been used logical operators.

     If_Ref Com(#ReferenceOne) Is_Not(*null)
     If Cond('#ReferenceOne.Left <= 0')
     Set #ReferenceOne Left(100)
     Endif
Endif

So it has been necessary to write two conditional commands in order to first ensure that the variable #ReferenceOne was not null and therefore could be referenced. The second conditional command then checked the state of the component before executing the SET command.

...

This means that the previous example can now be coded as:

     If Cond( (#ReferenceOne *IsNot *Null) *AndIf (#ReferenceOne.Left <= 0))
Set #ReferenceOne Left(100)
Endif

Example

The following code fragment shows the use of the *OrIf and *AndIf operators:

     ...
DEFINE_COM CLASS(#DEPTMENT) NAME(#DEPARTMENT)
SET COM(#COM_OWNER) PSCENARIO('(#ReferenceOne *isnot *null) *andif (#ReferenceOne.Left <= 0))')
(#ReferenceOne.Left <= 0))
IF COND((#DEPTMENT *IsNot *null) *AndIf (#DEPTMENT.Value = ADM))
SET COM(#pass) VALUE(TRUE)
ENDIF

SET COM(#COM_OWNER) PSCENARIO('if (#DEPTMENT.value = FIN) *orif (#section.value ''05'')')
IF ((#DEPTMENT.value = ADM) *OrIf (#section.value = '05'))
SET COM(#pass) VALUE(TRUE)
ENDIF

SET COM(#COM_OWNER) PSCENARIO('if cond( (#COM_OWNER.ComponentPatternName = QAP308) *andif (#com_self.componentpatternname = QAP308))')
IF ((#COM_OWNER.ComponentPatternName = QAP308) *AndIf (#com_self.componentpatternname = QAP308))
SET COM(#pass) VALUE(TRUE)
ENDIF
...