Action code

Variable declaration

Syntax:

    var <identifier> : <Sort> [:= <expression>];

Defines a variable within the current scope with name identifier of type Sort, with (optionally) initial value expression.

Statements

assignments
The syntax of an assignment:

    <variable> := <value expression>;

Example:

    p.lastName := "Doe";

if
The if-statement has the following syntax:

    if(<expression>) {
       <block executed if true>
    } [else {
       <block executed if false>
    }]

If the expression is true the first block of code is executed, if it's false, the second block is executed. The else block is optional. Example:

    if(user.lastName = "Doe") {
       msg := "You are unkown";
    }

for
The for-statement has the following syntax:

    for(<identifier> : <Sort> in <expression> [where <condition>] [order by <expression>]) {
        <code to be executed repetitively>
    }

Note: the implementation of order by is not stable yet.

Example:

    for(p : Person in persons where p.lastName = "Doe") {
       does.add(p)
    }

return
Syntax:

    return <expression>;

Example:

    return p.lastName;

In the context of a entity function this returns the expression as the result of that function. In the context of an action definition, it tells the action to redirect the user to the page specified in the expression.

goto
The goto statement (only allowed in the defintion of an action, not in function code) redirects the user to the specified page. Syntax:

    goto <page>([params]);

Example:

    goto editPage(p);

Contributions by ZefHemel