Share this page

# switch

Used to control conditional operations. Control passes to the operation whose case statement matches the value of switch(expression).

Copy code

    switch ( <i>variable</i> )
    {
        case const:
        <i>statements</i>...;
        default:
        <i>statements</i>...;
    }

## Example

The following example contains a switch statement that tests the value of rc. If rc's value is 1, then the transaction is deemed a success.

Copy code

        int rc;
        lr_start_transaction ("deposit");
        // Server API call
        rc = 1; // Place your own call here e.g., rc = bank_deposit (50);
        switch(rc) {
        case 1: lr_end_transaction ("deposit", LR_PASS);
            break;
        case 0: lr_end_transaction ("deposit", LR_PASS);
            break;
        case -1: lr_end_transaction ("deposit", LR_FAIL);
            break;
        }

    Example: Output:
    Action.c(5): Notify Transaction deposit started.
    Action.c(12): Notify Transaction deposit ended with Pass status (Duration: 0.0200).

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: