Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


6.2 Statements

A statement is normally a single instruction to the computer, and each statement normally occupies a single line. If you think of a procedure as a paragraph then a statement is a sentence. Using the same analogy, variables, expressions and keywords are the words which make up the sentence.

So far in our examples we have met only two kinds of statement: the single line statement and the multi-line statement. The assignments we have seen were single line statements, and the vertical form of the IF block is a multi-line statement. The horizontal form of the IF block was actually the single line statement form of the IF block. Notice that statements can be built up from other statements, as is the case for IF blocks. The code parts between the IF, ELSEIF, ELSE and ENDIF lines are sequences of statements.

Single line statements can often be very short, and you may be able to fit several of them onto an single line without the line getting too long. To do this in E you use a semi-colon (the `;' character) to separate each statement on the line. For example, the following code fragments are equivalent:

  fred(y,z)
  y:=x
  x:=z+1

  fred(y,z); y:=x; x:=z+1

On the other hand you may want to split a long statement over several lines. This is a bit more tricky because the compiler needs to see that you haven't finished the statement when it gets to the end of a line. Therefore you can only break a statement at certain places. The most common place is after a comma that is part of the statement (like in a procedure call with more than one parameter), but you can also split a line after binary operators and anywhere between opening and closing brackets. The following examples are rather silly but show some allowable line breaking places.

   fred(a, b, c,
        d, e, f)   /* After a comma */

   x:=x+
      y+
      z            /* After a binary operator */

   x:=(1+2
       +3)         /* Between open...close brackets */

   list:= [ 1,2,
            [3,4]
           ]       /* Between open...close brackets */

The simple rule is this: if a complete line can be interpreted as a statement then it will be, otherwise it will be interpreted as part of a statement which continues on the following lines.

Strings may also get a bit long. You can split them over several lines by breaking them into several separate strings and using `+' between them. If a line ends with a `+' and the previous thing on the line was a string then the E compiler takes the next string to be a continuation. The following calls to WriteF print the same thing:

  WriteF('This long string can be broken over several lines.\n')

  WriteF('This long string ' +
         'can be broken over several lines.\n')

  WriteF('This long' +
         ' string can be ' +
         'broken over several ' +
         'lines.\n')


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.