Last modified 3 years ago Last modified on 12/27/08 22:54:03

Control structures are used to control the program flow.

if statements

if statements are used to control which bits of code are executed. The simplest form is:

if (<bool exp>)
{
        <code>
}

In this form if <bool exp> evaluates to true, then the script code <code> is executed, otherwise the code is ignored.

Examples:

if (<bool exp>)
{
        <code>
}
else
{
        <other code>
}

if (<bool exp>)
{
        <code>
}
else if (<other bool exp>)
{
        <other code>
}
else
{
        <yet another code>
}

while statements

While statements allow <code> to be executed as long as <bool exp> evaluates to TRUE. This allows for looping a specific piece of <code>. Be careful to not create an infinite loop:

while (<bool exp>)
{
        <code>
}

{{Scripting manual}} Category:Scripting manual ?