Aug.06.2020 -- CAlive to introduce if any/all .. succeed .. fail blocks

17 views
Skip to first unread message

Rick C. Hodgin

unread,
Aug 6, 2020, 12:46:42 PM8/6/20
to caliveprogra...@googlegroups.com
CAlive will introduce the if any ... succeed ... fail and if all ... succeed ... fail blocks, allowing for a large number of logic tests to be conducted with intermediate results being set on success or failure of each test.  The succeed and fail portions are optional.

On the if any, if any of them succeed it will enter the block, otherwise it will enter the else.
On the if all, if all of them succeed it will enter the block, otherwise it will enter the else.

This can also be combined with flow { }  block logic to perform multiple operations in isolated areas making the source code cleaner.

    if any
    | (expression1) succeed name1s fail name1f
    | (expression2) succeed expression2 fail expression2
    | (expression3) succeed expression3 fail expression3
    | (expression4) succeed expression4 fail expression4
    {
        // Code here if any of them pass [if any]
        // Code here if all of them pass [if all]

    } else if any
    | (expression5) succeed expression2
    | (expression6) fail expression3
    | (expression7)
    {

    } else {
        // Code here if it fails

    } flow name1s {
        // Code here for the expression1 success

    } flow name1f {
        // Code here for the expression1 fail
    }

You can also use a decision cask to encapsulate the code more succinctly (remember, the syntax is <|| cond | if true | if false ||>.  Since in this case the condition is external, it is contextually using the result of the indicated expression.

    if all
    | (expression1) <|name1s | name1f||>
    | (expression2) <|expression2 |expression2||>
    | (expression3) <|expression3 |expression3||>
    | (expression4) <|expression4 |expression4||>

The if all works identically, except that it uses the if all keyword.
-- 
Rick C. Hodgin

Reply all
Reply to author
Forward
0 new messages