DriveWorks Solo 15: If [send feedback...]

Syntax

IF( [ Condition], [ ValueIfConditionIsTrue], [ ValueIfConditionIsFalse] )

Condition is any rule which, when calculated, returns either TRUE or FALSE.

ValueIfConditionIsTrue is a rule or value which is returned if the condition, when calculated, returns TRUE.

ValueIfConditionIsFalse is a rule or value which is returned if the condition, when calculated, returns FALSE.

Examples

Rule

Meaning
IF( FormSpinButtonReturn<=5, "Can be shipped in one container", "Will be shipped in several packages.")Checks the return value from a spin button called FormSpinButton, and if the result is less than or equal to five, returns "Can be shipped in one container".

Comparing Values

Operator

Meaning
<Checks to see if the value on the left hand side of the operator is less than the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.
<=Checks to see if the value on the left hand side of the operator is less than, or equal to, the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.
>Checks to see if the value on the left hand side of the operator is greater than the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.
>=Checks to see if the value on the left hand side of the operator is greater than, or equal to, the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.
<>Checks to see if the value on the left hand side of the operator is not equal to the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.
=Checks to see if the value on the left hand side of the operator is the same as the value on the right hand side, and if so, returns TRUE, otherwise returns FALSE.

Nesting IF

Multiple IF statements can be nested so many conditions can be evaluated. In these cases the syntax of the single IF statement is substituted for one of the conditions, as below:

IF( [ ConditionA], [ ValueIfConditionAIsTrue],  IF( [ ConditionB], [ ValueIfConditionBIsTrue], [ ValueIfConditionBIsFalse] ) )

IF statements are always evaluated from left to right. So in the example above

  • ConditionA is evaluated first
  • When ConditionA is TRUE the ValueIfConditionAIsTrue will be the result of the IF statement. The remainder of the nested IF will be ignored.
  • When ConditionA is FALSE the value in the second condition would usually be the result. But the example above initiates the evaluation of ConditionB
  • When ConditionB is TRUE the ValueIfConditionBIsTrue will be the result of the IF statement. The remainder of the nested IF will be ignored.
  • When ConditionB is FALSE the ValueIfConditionBIsFalse will be the result
There are no limits on the amount of IF functions that can be nested as ValueIfTrue and ValueIfFalse arguments. Alternatively, to test many conditions, consider using tables and the functions DWVLookup  and VLookup

IF AND/IF ORc

The AND and OR functions can be nested in place of the Condition argument. In these cases the syntax of the AND/OR function replaces the Condition portion of the IF statement. For example:

IF( AND ( [ LogicalExpression1], [ LogicalExpression2] ) , [ ValueIfConditionIsTrue], [ ValueIfConditionIsFalse] )

When using AND

  • When all LogicalExpressions within the AND function are TRUE the ValueIfConditionIsTrue will be the result
  • When any of the LogicalExpressions within the AND function are FALSE the ValueIfConditionIsFalse will be the result

IF( OR ( [ LogicalExpression1], [ LogicalExpression2] ) , [ ValueIfConditionIsTrue], [ ValueIfConditionIsFalse] )

When OR

  • When any of the LogicalExpressions within the OR function are TRUE the ValueIfConditionIsTrue will be the result
  • When all of the LogicalExpressions within the OR function are FALSE the ValueIfConditionIsFalse will be the result

Table of Contents