Statements and Blocks

 

An expression such as x = 0 or j++ becomes a statement when it is followed by a semicolon, as in:

 

x = 0;

j++;

 

Expressions may be entered interactively in a DADiSP session. For example, to define a global variable that contains the range of the data in W1, type:

 

r1 = max(w1) - min(w1)

 

Because only one expression has been entered interactively, the ; terminator is not required. Multiple expressions must be separated by semicolons such as:

 

r1 = max(w1) - min(w1); r2 = r1^2

 

Because functions consist of one or more statements, the terminating semicolon is always required.

 

/* return the data range of the input series */

drange(s)
{
    local r1;
 
    r1 = max(s) - min(s);
 
    return(r1);
}

 

Like C/C++, the opening and closing braces, { and } are used to group statements together into a compound statement or block so that they are equivalent to a single statement. The braces that surround the statements of a function are an example.