home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Demos / Extend 3.0 Demo / Extend Demo / Extend Demo.rsrc / HELP_265_ ModL Control Statements < prev    next >
Encoding:
Text File  |  1994-07-14  |  2.3 KB  |  85 lines

  1. ModL supports a full complement of structured programming control statements. In this list, "boolean" evaluates to true or false. STATEMENTS means either a single “statement;” or multiple statements grouped by braces:
  2.   {
  3.   statement;
  4.   ...... 
  5.   statement;
  6.   } // note no semicolon here
  7.  
  8. Returns are ignored, and statements may use several lines. The control statements (in alphabetical order) are:
  9.  
  10. • ABORT
  11. Stops the current message handler.
  12. ABORT;
  13.  
  14. • BREAK
  15. Immediately exits an enclosing FOR, WHILE, DO, or SWITCH statement.
  16. BREAK;
  17.  
  18. • CONTINUE
  19. Immediately sends control to the next iteration of an enclosing FOR, WHILE, or DO loop.
  20. CONTINUE;
  21.  
  22. • DO-WHILE
  23. Repeats the statement while the expression is true; tests at the end of the loop.
  24. DO
  25.     STATEMENT;           // see definition of multiple statements above
  26. WHILE (boolean);       // Note semicolon
  27.  
  28. • FOR (BASIC variation, see C variation below)
  29. FOR id = init TO top STEP increment
  30.     STATEMENT;
  31. or
  32. FOR id = init TO top
  33.     STATEMENT;
  34.     
  35. • FOR (C variation, see BASIC variation above)
  36. Lets you set the initial value, continuing boolean condition, and action to take.
  37. FOR (init_assignment; boolean; incr_assignment)
  38.     STATEMENT;        // see definition of multiple statements above
  39.  
  40. • GOTO
  41. Supported only within a message handler or user defined function. Control is unconditionally transferred to the statements after the label.
  42. GOTO label;
  43. ...
  44. label:    //note the colon after the label
  45. ...
  46.  
  47. • IF
  48. Used for boolean comparisons
  49. If (boolean)
  50.     STATEMENT;     // see definition of multiple statements above
  51.  
  52. • IF-ELSE
  53. Used for boolean comparisons if you have two paths to choose from
  54. If (boolean)
  55.     STATEMENTA;     // see definition of multiple statements above
  56. else
  57.     STATEMENTB;     // see definition of multiple statements above
  58.         
  59. • RETURN
  60. Used to exit message handlers and user-defined functions.
  61. RETURN;
  62. or
  63. RETURN(value or expression);
  64.  
  65. • SWITCH
  66. Used to check values against integer constants and act on those cases. 
  67. SWITCH (expression)
  68.     {
  69.     CASE integerConstant:
  70.         zero to many STATEMENTS;
  71.         BREAK;
  72.     CASE integerConstant:
  73.         zero to many STATEMENTS;
  74.         BREAK;
  75.     DEFAULT:
  76.         zero to many STATEMENTS;
  77.         BREAK;
  78.     }
  79.  
  80. • WHILE
  81. Repeats the statement while the expression is true; the expression is evaluated at the beginning of the loop.
  82. WHILE (boolean)    // Note no semicolon
  83.     STATEMENT;     // see definition of multiple statements above
  84.  
  85.