home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / modula2 / tutorial / programs / ifdemo.mod < prev    next >
Text File  |  1993-03-14  |  1KB  |  35 lines

  1.                                          (* Chapter 4 - Program 2 *)
  2. MODULE IfDemo;
  3.  
  4. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  5.  
  6. VAR Index1 : INTEGER;
  7.  
  8. BEGIN
  9.  
  10.    FOR Index1 := 1 TO 8 DO
  11.       IF Index1 < 4 THEN                   (* Simple IF statement *)
  12.          WriteString("Index1 is less than 4.");
  13.          WriteInt(Index1,4);
  14.          WriteLn;
  15.       END;  (* end of first IF statement *)
  16.  
  17.       IF Index1 = 5 THEN                   (* two way IF statement *)
  18.          WriteString("Index1 is 5");
  19.       ELSE
  20.          WriteString("Index1 is not 5");
  21.       END;  (* end of second IF statement *)
  22.       WriteLn;
  23.  
  24.       IF Index1 = 2 THEN              (* multiple way IF statement *)
  25.          WriteString("Index1 is 2");
  26.       ELSIF Index1 = 6 THEN
  27.          WriteString("Index1 is 6");
  28.       ELSE
  29.          WriteString("I really don't care what Index1 is");
  30.       END;  (* end of third IF statement *)
  31.       WriteLn;
  32.    END;  (* of big FOR loop *)
  33.  
  34. END IfDemo.
  35.