if_on_server

Runs its block only when the code around it has been placed on the server. It does not move code: the compiler decides where the surrounding code runs, and if_on_server merely reacts to that decision. When the surrounding code lands on the device, the block is left out of the app. Write it as a pair with an if_on_client block in the same block of code: the pair says what happens on each side, so that one piece of code (a macro, a preset, a reusable routine) is right wherever the compiler places it; the half that does not apply is dropped on purpose. An if_on_server whose block is left out and that has no if_on_client beside it is a compile warning: the answer is the missing half, never moving the code, adding location declarations or splitting the activity.

Runs on: either side: the compiler places the statement that calls it where the values it uses live.

Format:

if_on_server { [statements] }

Examples

// a check that must hold on either side: each half does it for its tier
if_on_client {
    if (qty < 1) {
        abort("Enter a quantity")
    }
}
if_on_server {
    if (qty < 1) {
        abort("Enter a quantity")
    }
}