CabMasterPro User Guide
In This Topic
    Selection
    In This Topic

    Selection Structures

    These let a formula return different results depending on a value, a test or a comparison

    IF function

    Returns a value if a test condition evaluates to TRUE and another value if it evaluates to FALSE.

    Syntax:
    IF ( logical_test1, stat_list1, [ logical_test2, stat_list2, ]... stat_list_else )

    IFF ( logical_test1, stat_list1, [ logical_test2, stat_list2, ]... stat_list_else )

    IF THEN ELSE

    Evaluate one statement list if a test condition evaluates to TRUE and another statement list if it evaluates to FALSE.

    Syntax:
    IF logical_test1 THEN stat_list1 [ ELSE IF logical_test2 THEN statlist2 ]... [ ELSE stat_list_else ] [ END IF ]

    IF logical_test1 THEN BEGIN stat_list1 END [ ELSE IF logical_test2 THEN BEGIN statlist2 END ]... [ ELSE BEGIN stat_list_else END]

    IF ( logical_test1 ) { stat_list1 } [ ELSE IF ( logical_test2 ) { statlist2 } ]... [ ELSE { stat_list_else } ]
    Example:
    IF mark > 50 THEN "pass" ELSE "fail" ENDIF

    SELECT

    Evaluates the statement associated with a value, depending on which case matches the test value. This differs from the IF THEN ELSE type selection because it is specifically designed for multiple cases, not just true and false.

    Syntax:
    SELECT [CASE] test
          CASE value1 [ : ] stat_list1
          CASE from2 TO upto2 [ : ] stat_list2
          CASE IS op value3 [ : ] stat_list3
          CASE ELSE stat_list_else
    END SELECT

    CASE test OF
          value1 : stat_list1
          from2 TO upto2 : stat_list2
          IS op value3 : stat_list3
          ELSE stat_list_else
    END

    SWITCH ( test ) {
          CASE value1 : stat_list1
          CASE from2 TO upto2 : stat_list2
          CASE IS op value3 : stat_list3
          DEFAULT : stat_list_else
    }

    Example:
    SELECT count
          CASE 0 : "None"
          CASE 1 : "One"
          CASE 2 : "A couple"
          CASE 3, 4, 5 : "A few"
          CASE 10 TO 20 : "Many"
          CASE IS > 20 : "A lot"
          CASE ELSE "Several"
    END SELECT

    TRY CATCH

    Evaluate statements, and if there is an error evaluate the catch statement.

    Syntax:
    TRY statlist CATCH statlist_catch [ END TRY | END CATCH ]

    IF mark > 50 THEN "pass" ELSE "fail" ENDIF