Thursday, November 4, 2010

SOFT6001 Week 08

We looked at loops. Loos can be very tricky.

notes and video
Loop exercises

The Microsoft ELSEIF:
When I am Emperor of the World the ELSEIF will be first against the wall.

Many programming languages nest IFs like this:

IF x < 10 THEN
      B = 9
ELSE
     IF x< 20 THEN
          B = 10
     ELSE
          IF x < 30 THEN
               B = 11
          ELSE
               B = 12
          ENDIF
     ENDIF
ENDIF

Notice how there is an ENDIF for every IF.

In VB is it possible to say:


IF x < 10 THEN
      B = 9
ELSEIF x< 20 THEN
          B = 10
ELSEIF x < 30 THEN
               B = 11
ELSE
               B = 12
ENDIF

Here the nested structure is lost. This is very inelegant.

No comments: