home *** CD-ROM | disk | FTP | other *** search
/ norge.freeshell.org (192.94.73.8) / 192.94.73.8.tar / 192.94.73.8 / pub / computers / cpm / alphatronic / ALGOL-M.ZIP / USRMAN.TXT < prev    next >
Text File  |  1999-03-13  |  25KB  |  1,499 lines

  1.   
  2.          ALGOL-M LANGUAGE REFERENCE MANUAL
  3.  
  4.  
  5. This section describes the various elements of the ALGOL-M
  6. language.
  7. The format of the element will be shown,  followed by a description
  8. and examples of use.  The following notation is used:
  9.         Braces {} indicate an optional entry.
  10.         A vertical bar | indicates alternate choices, one of
  11.         which must appear.
  12.         Elipses "..." indicate that the preceding item may
  13.         be optionally repeated.
  14.         Reserved words are indicated by capital letters.
  15.         Reserved words and other special symbols must appear as
  16.         shown.
  17.         Items appearing in small letters are elements of the
  18.         language which are defined and explained elsewhere in
  19.         the language manual.
  20.  
  21.                                         arithmetic expression
  22.  
  23.  
  24. ELEMENT:
  25.  
  26.       arithmetic expression
  27.  
  28.  
  29.  
  30. FORMAT:
  31.  
  32.  
  33.       integer|decimal
  34.  
  35.  
  36.  
  37.       variable
  38.  
  39.  
  40.  
  41.       {(} arithmetic expression  binary operator
  42.  
  43.       arithmetic expression {)}
  44.  
  45.  
  46.  
  47.       {(} unary operator  arithmetic expression {)}
  48.  
  49.  
  50.  
  51. DESCRIPTION:
  52.  
  53.  
  54.       Operators in ALGOL-M have an implied  precedence  which  is
  55.  
  56.       used  to  determine  the  manner  in  which  operators  and
  57.  
  58.       operands are grouped.  A-B/C causes the result of B divided
  59.  
  60.       by C to be subtracted from A.  In this case B is considered
  61.  
  62.       to be "bound" to  the  "/"  operator  instead  of  the  "-"
  63.  
  64.       operator  which  causes the division to be performed first.
  65.  
  66.       The implied  precedence  binds  operands  to  the  adjacent
  67.  
  68.       operator  of highest precedence.  The implied precedence of
  69.  
  70.       operators is as follows:
  71.  
  72.          unary  -,+
  73.  
  74.                  **
  75.  
  76.                  *,/
  77.  
  78.                  +,-
  79.  
  80.       Parentheses can be used to override the implied  precedence
  81.  
  82.       in the same way as they are used in ordinary algebra.  Thus
  83.  
  84.       the expression (A-B)/C will cause B to be subtracted from A
  85.  
  86.       and the result divided by C.
  87.  
  88.  
  89. EXAMPLE:
  90.  
  91.       (X + Y) * (Z * Y + X) ** 2
  92.  
  93.       X + Y + Z * X * Y * Z / 5.456 + I
  94.  
  95.                                         ARRAY declaration
  96.  
  97.  
  98. ELEMENT:
  99.  
  100.       ARRAY declaration
  101.  
  102.  
  103.  
  104. FORMAT:
  105.  
  106.  
  107.       INTEGER|DECIMAL|STRING {(expression)} ARRAY
  108.  
  109.       identifier ... bound pair list {,identifier}
  110.  
  111.  
  112.  
  113. DESCRIPTION:
  114.  
  115.  
  116.       The array declaration  dynamically  allocates  storage  for
  117.  
  118.       arrays.   The  optional  integer  expression  indicates the
  119.  
  120.       length of each array element.  For  strings,   the  maximum
  121.  
  122.       length  is  255  characters  and  for  decimals the maximum
  123.  
  124.       length is 18 digits.  Integer  lengths  are  not  specified
  125.  
  126.       since  storage  adequate  to  represent  all integer values
  127.  
  128.       between -16,383 and  +16,383  is  automatically  allocated.
  129.  
  130.       Arrays are not automatically initialized to zero.
  131.  
  132.  
  133. EXAMPLE:
  134.  
  135.       INTEGER ARRAY X[0:5,0:5];
  136.  
  137.       DECIMAL(10) ARRAY X,Y[3:6,5:10];
  138.  
  139.       STRING ARRAY  WORDS[Y+3:12];
  140.  
  141.       STRING(20) WORD[0:X+5,5:10,15:20];
  142.  
  143.                                         assignment statement
  144.  
  145.  
  146. ELEMENT:
  147.  
  148.       assignment statement
  149.  
  150.  
  151.  
  152. FORMAT:
  153.  
  154.  
  155.       variable := {variable :=} ... expression
  156.  
  157.  
  158.  
  159. DESCRIPTION:
  160.  
  161.  
  162.       The expression is evaluated and stored into  the  variable.
  163.  
  164.       The  types  of permissible assignments are indicated by the
  165.  
  166.       following table:
  167.  
  168.                                       expression
  169.  
  170.  
  171.                                 integer  decimal  string
  172.  
  173.  
  174.                       integer     yes      no       no
  175.  
  176.  
  177.             variable  decimal     yes      yes      no
  178.  
  179.  
  180.                       string      no       no       yes
  181.  
  182.  
  183.       Multiple assignments are allowed with the expression  being
  184.  
  185.       assigned to all of the listed variables.
  186.  
  187.  
  188. EXAMPLE:
  189.  
  190.       X := Y + Z;
  191.  
  192.       Y[1] := Y[2] := 50;
  193.  
  194.                                         assignment on the fly
  195.  
  196.  
  197. ELEMENT:
  198.  
  199.       assignment on the fly
  200.  
  201.  
  202.  
  203. FORMAT:
  204.  
  205.  
  206.       ( variable := { variable := } ... expression )
  207.  
  208.  
  209.  
  210.  
  211. DESCRIPTION:
  212.  
  213.  
  214.       Algol-m allows a special form of the  assignment  statement
  215.  
  216.       known as assignment on the fly.  This form of an assignment
  217.  
  218.       statement can be used anywhere an  expression  is  allowed.
  219.  
  220.       The  expression  to the right of the := symbol is evaluated
  221.  
  222.       and then stored into the variable on the left.   The  value
  223.  
  224.       of  the entire expression is the same as that of it's right
  225.  
  226.       half. The only difference is the side-effect of storing the
  227.  
  228.       intermediate  result  into the variable on the left.  These
  229.  
  230.       intermediate results can then be used at a later  point  in
  231.  
  232.       the program without re-calculating them.
  233.  
  234.  
  235. EXAMPLE:
  236.  
  237.       A:= (B:=C + 5) * 2;
  238.  
  239.       IF (B:=C:=D+5) > 10 THEN
  240.           WRITE(B);
  241.  
  242.                                         balanced statement
  243.  
  244.  
  245. ELEMENT:
  246.  
  247.       balanced statement
  248.  
  249.  
  250.  
  251. FORMAT:
  252.  
  253.  
  254.       {label definition} simple statement
  255.  
  256.  
  257.  
  258.       {label definition} IF boolean expression THEN balanced
  259.  
  260.       statement ELSE balanced statement
  261.  
  262.  
  263.  
  264. DESCRIPTION:
  265.  
  266.  
  267.       If the boolean expression is true, the  balanced  statement
  268.  
  269.       to  the  left  of  the  ELSE  is  executed.  If the boolean
  270.  
  271.       expression is false, the balanced statement to the right of
  272.  
  273.       the ELSE is executed.
  274.  
  275.  
  276. EXAMPLE:
  277.  
  278.       IF A < B THEN A := 1 ELSE A := 2;
  279.  
  280.       IF B = C THEN
  281.          BEGIN
  282.            WRITE(B);
  283.            B := B + 1;
  284.          END
  285.       ELSE
  286.          BEGIN
  287.            WRITE(C);
  288.            C := C + 1;
  289.          END;
  290.  
  291.  
  292. PROGRAMMING NOTE:
  293.  
  294.  
  295.       A semicolon is not allowed after the statement  immediately
  296.  
  297.       preceding an ELSE.
  298.  
  299.  
  300.                                         block
  301.  
  302.  
  303.  
  304. ELEMENT:
  305.  
  306.  
  307.       block
  308.  
  309.  
  310.  
  311. FORMAT:
  312.  
  313.  
  314.       BEGIN {declaration;} ... statement; ... END;
  315.  
  316.  
  317.  
  318. DESCRIPTION:
  319.  
  320.  
  321.       The block is the foundation of the ALGOL-M language.   Each
  322.  
  323.       time  a new block is entered new variables may be declared.
  324.  
  325.       These variables are unique in the sense that a  variable  X
  326.  
  327.       declared  in  two different blocks represents two different
  328.  
  329.       variables.  All storage  within  a  block  is  dynamic  and
  330.  
  331.       allocated  when  the block is entered and de-allocated when
  332.  
  333.       the block is departed.  A block can be  used  any  place  a
  334.  
  335.       simple statement can be used.
  336.  
  337.  
  338. EXAMPLE:
  339.  
  340.          BEGIN
  341.          X := 1;
  342.          Y := 2;
  343.          END;
  344.  
  345.          IF X = Y THEN
  346.            BEGIN
  347.            INTEGER X,Y;
  348.            X := 3;
  349.            Y := 4;
  350.            END;
  351.  
  352.  
  353. PROGRAMMING NOTE:
  354.  
  355.  
  356.       Declarations may not appear in case blocks.  The final END,
  357.  
  358.       which matches the initial program BEGIN, is not followed by
  359.  
  360.       a semicolon.
  361.  
  362.  
  363.                                         boolean expression
  364.  
  365.  
  366.  
  367. ELEMENT:
  368.  
  369.  
  370.       boolean expression
  371.  
  372.  
  373.  
  374. FORMAT:
  375.  
  376.  
  377.       NOT boolean expression
  378.  
  379.       boolean expression OR boolean expression
  380.  
  381.       boolean expression AND boolean expression
  382.  
  383.       {(} expression =|<|>|>=|<=|<> expression {)}
  384.  
  385.  
  386.  
  387. DESCRIPTION:
  388.  
  389.  
  390.       Integer-integer,     decimal-integer,      decimal-decimal,
  391.  
  392.       integer-decimal,  and string-string comparisons are allowed
  393.  
  394.       in  ALGOL-M.   For  integer-decimal   and   decimal-integer
  395.  
  396.       comparisons  the  integer  value  is converted to a decimal
  397.  
  398.       value prior to comparison.  The result of a  comparison  of
  399.  
  400.       numerical  values is based on the size of the numbers.  The
  401.  
  402.       result of a  comparison  of  string  values  depends  on  a
  403.  
  404.       character-by-character  comparison where the first instance
  405.  
  406.       of a non-equal character establishes  the  boolean  result.
  407.  
  408.       The  collating  sequence of the ASCII character set is used
  409.  
  410.       for string comparisons.  Generally, numbers are followed by
  411.  
  412.       upper  case  letters  which  are  followed  by  lower  case
  413.  
  414.       letters.
  415.  
  416.  
  417. EXAMPLE:
  418.  
  419.       X > Y OR Y < Z;
  420.  
  421.       (X = Y) AND (Y = Z OR Z = 10);
  422.  
  423.       IF NOT X = 1 THEN WRITE("HELLO");
  424.  
  425.                                         bound pair list
  426.  
  427.  
  428. ELEMENT:
  429.  
  430.       bound pair list
  431.  
  432.  
  433.  
  434. FORMAT:
  435.  
  436.  
  437.       [expression : expression{,expression : expression} ...]
  438.  
  439.  
  440.  
  441. DESCRIPTION:
  442.  
  443.  
  444.       Expressions in the bound pair list must be of type  integer
  445.  
  446.       and  greater  than  or equal to zero.  There can be no more
  447.  
  448.       than 255 dimensions.
  449.  
  450.  
  451. EXAMPLE:
  452.  
  453.       [1:7,0:5]
  454.  
  455.       [3:6,x:y]
  456.  
  457.       [y*3:z,1:12]
  458.  
  459.                                         CASE statement
  460.  
  461.  
  462. ELEMENT:
  463.  
  464.       CASE statement
  465.  
  466.  
  467.  
  468. FORMAT:
  469.  
  470.  
  471.       CASE expression OF
  472.  
  473.            BEGIN
  474.  
  475.            statement; ...
  476.  
  477.            END;
  478.  
  479.  
  480.  
  481. DESCRIPTION:
  482.  
  483.  
  484.       The CASE statement allows the programmer to  choose  one  of
  485.  
  486.       several  statements  to  be executed.  The statement chosen
  487.  
  488.       depends on the value of the integer expression.  The  first
  489.  
  490.       statement  is executed if the expression evaluates to zero.
  491.  
  492.       If the value of the expression is greater than  the  number
  493.  
  494.       of  statements  in the case block,  the resulting action is
  495.  
  496.       undefined.
  497.  
  498.  
  499.    EXAMPLE:
  500.  
  501.         CASE X+Y OF
  502.             BEGIN
  503.            WRITE("CASE 0");
  504.            WRITE("CASE 1");
  505.            END;
  506.  
  507.                      constant
  508.  
  509.  
  510. ELEMENT:
  511.  
  512.       constant
  513.  
  514.  
  515.  
  516. FORMAT:
  517.  
  518.  
  519.       integer|decimal|string
  520.  
  521.  
  522.  
  523. DESCRIPTION:
  524.       A constant may be either an integer, decimal, or
  525.       string constant.  Integer constants are numbers with
  526.       no decimal point ranging from -16383 to +16383.
  527.       Decimal constants are numbers with a decimal point and
  528.       may not exceed 18 digits in length.  String constants
  529.       may be composed of any combination of alphanumeric and 
  530.       special characters and may be up to 255 characters in length.  
  531.       Strings entered from the console or disk may be either enclosed 
  532.       in quotation marks or delimitd with commas.  Strings used as
  533.       constants in the program must be enclosed in quotation marks.
  534.  
  535.  
  536.  
  537. EXAMPLE:
  538.  
  539.       10
  540.  
  541.       10.5678
  542.  
  543.       "EXAMPLE ONE"
  544.                                         declaration
  545.  
  546.  
  547. ELEMENT:
  548.  
  549.       declaration
  550.  
  551.  
  552.  
  553. DESCRIPTION:
  554.  
  555.  
  556.  
  557.       See FILE   declaration,  ARRAY declaration,   simple
  558.  
  559.       declaration,    procedure    declaration,    and   function
  560.  
  561.       declaration.
  562.  
  563.  
  564.  
  565.  
  566.                                               expression
  567.  
  568.  
  569. ELEMENT:
  570.  
  571.  
  572.       expression
  573.  
  574.  
  575.  
  576. FORMAT:
  577.  
  578.  
  579.       boolean expression|arithmetic expression
  580.  
  581.  
  582.  
  583. DESCRIPTION:
  584.  
  585.  
  586.       See arithmetic expression and boolean expression.
  587.  
  588.  
  589.                                         FILE declaration
  590.  
  591.  
  592.  
  593. ELEMENT:
  594.  
  595.  
  596.       FILE declaration
  597.  
  598.  
  599.  
  600. FORMAT:
  601.  
  602.  
  603.       FILE identifier {(expression)} {,identifier
  604.  
  605.       {(expression)}} ...
  606.  
  607.  
  608.  
  609. DESCRIPTION:
  610.  
  611.  
  612.       The identifiers used  in  the  FILE  declaration  are  file
  613.  
  614.       identifiers  which reference actual file names.  The actual
  615.  
  616.       file names may be assigned at compile-time or at  run-time.
  617.  
  618.       The   optional   integer   expression  following  the  file
  619.  
  620.       identifier is used to specify the record  length  in  bytes
  621.  
  622.       for blocked records.
  623.  
  624.  
  625. EXAMPLE:
  626.  
  627.       FILE TAPE1, TAPE2(128);
  628.  
  629.  
  630. PROGRAMMING NOTE:
  631.  
  632.  
  633.       Blocked records are not implemented.
  634.  
  635.                                         FOR statement
  636.  
  637.  
  638. ELEMENT:
  639.  
  640.       FOR statement
  641.  
  642.  
  643.  
  644. FORMAT:
  645.  
  646.  
  647.       {label definition} FOR assignment statement
  648.  
  649.       STEP expression UNTIL expression DO simple statement
  650.  
  651.  
  652.  
  653. DESCRIPTION:
  654.  
  655.  
  656.       Execution of all statements within the simple statement are
  657.  
  658.       repeated  until  the  indexing  variable is greater than or
  659.  
  660.       equal to the value of the UNTIL expression.   The  indexing
  661.  
  662.       variable is incremented by the amount specified in the STEP
  663.  
  664.       expression and must be incremented by  a  positive  amount.
  665.  
  666.       The UNTIL and STEP expressions are evaluated on each loop.
  667.  
  668.  
  669. EXAMPLE:
  670.  
  671.       FOR I := 1 STEP 1 UNTIL 10 DO
  672.           X := Y;
  673.  
  674.       FOR INDEX := X+Y STEP 2 UNTIL X*Y DO
  675.           BEGIN
  676.           A := A + B;
  677.           WRITE(A);
  678.           END;
  679.  
  680.                                         function call
  681.  
  682.  
  683. ELEMENT:
  684.  
  685.       function call
  686.  
  687.  
  688.  
  689. FORMAT:
  690.  
  691.  
  692.       identifier {(expression {,expression} ...)}
  693.  
  694.  
  695.  
  696. DESCRIPTION:
  697.  
  698.  
  699.       Functions may appear as primary elements in  arithmetic  or
  700.  
  701.       boolean   expressions.   Parameter  passing  is  by  value.
  702.  
  703.       Functions may be called recursively with no  limit  to  the
  704.  
  705.       number of recursive calls allowed.
  706.  
  707.  
  708. EXAMPLE:
  709.  
  710.       X := RAND;
  711.  
  712.       Y := SQRT(5.6);
  713.  
  714.       C := FUNC * RND(2);
  715.  
  716.                                         function declaration
  717.  
  718.  
  719. ELEMENT:
  720.  
  721.       function declaration
  722.  
  723.  
  724.  
  725. FORMAT:
  726.  
  727.  
  728.       INTEGER|DECIMAL|STRING FUNCTION identifier
  729.  
  730.       {(identifier {,identifier} ...)}
  731.  
  732.       {declaration; ...} simple statement;
  733.  
  734.  
  735.  
  736. DESCRIPTION:
  737.  
  738.  
  739.       A function declaration may or may not  include  parameters.
  740.  
  741.       If parameters are included they must be declared before the
  742.  
  743.       simple statement which represents the body of the function.
  744.  
  745.       Parameters  are passed by value and may be of type integer,
  746.  
  747.       decimal, or string.  Functions return a value to the  point
  748.  
  749.       of  call.   The  value  to  be  returned is assigned to the
  750.  
  751.       function name (which is used as a  simple  variable  within
  752.  
  753.       the  function) prior to the end of the function.  Functions
  754.  
  755.       may be called recursively with  no  limit  set  as  to  the
  756.  
  757.       number  of recursive calls which can be made. Variables may
  758.  
  759.       be declared within functions and are  considered  local  to
  760.  
  761.       the function.
  762.  
  763.  
  764.  
  765.  
  766. EXAMPLE:
  767.  
  768.       INTEGER FUNCTION VALUE(X);
  769.          INTEGER X;
  770.          BEGIN
  771.          X := (X * 5) + (X * 2 );
  772.          VALUE := X;
  773.          END;
  774.  
  775.                                         GOTO statement
  776.  
  777.  
  778. ELEMENT:
  779.  
  780.       GOTO statement
  781.  
  782.  
  783.  
  784. FORMAT:
  785.  
  786.  
  787.       label definition GO TO identifier|integer
  788.  
  789.       label definition GOTO identifier|integer
  790.  
  791.  
  792.  
  793. DESCRIPTION:
  794.  
  795.  
  796.       Execution continues  at  the  statement  labeled  with  the
  797.  
  798.       identifier   or   integer  following  the  GOTO  or  GO  TO
  799.  
  800.       statement.
  801.  
  802.  
  803. EXAMPLE:
  804.  
  805.       NEXT: GO TO 100;
  806.  
  807.       100: GOTO NEXT;
  808.  
  809.  
  810. PROGRAMMING NOTE:
  811.  
  812.  
  813.       GOTO statements can only  be  used  to  branch  within  the
  814.  
  815.       current  block  or  to  an  outer  block.   GOTO statements
  816.  
  817.       branching out of subroutines can cause unkown results.
  818.  
  819.  
  820.                                         identifier
  821.  
  822.  
  823.  
  824. ELEMENT:
  825.  
  826.  
  827.       identifier
  828.  
  829.  
  830.  
  831. FORMAT:
  832.  
  833.  
  834.       letter {letter|number} ...
  835.  
  836.  
  837.  
  838. DESCRIPTION:
  839.  
  840.  
  841.       Identifiers begin with a letter and are continued with  any
  842.  
  843.       alphanumeric  characters.   Although  identifiers up to 255
  844.  
  845.       characters may be used, only the first  31  characters  are
  846.  
  847.       actually used to distinguish the identifiers.
  848.  
  849.  
  850. EXAMPLE:
  851.  
  852.       A
  853.  
  854.       NAME
  855.  
  856.       COUNTER1
  857.  
  858.                                         IF statement
  859.  
  860.  
  861. ELEMENT:
  862.  
  863.       IF statement
  864.  
  865.  
  866.  
  867. DESCRIPTION:
  868.  
  869.  
  870.       See balanced statement or unbalanced statement.
  871.  
  872.  
  873.                                         if expression
  874.  
  875.  
  876.  
  877. ELEMENT:
  878.  
  879.  
  880.       if expression
  881.  
  882.  
  883.  
  884. FORMAT:
  885.  
  886.  
  887.       IF boolean expression THEN expression ELSE expression
  888.  
  889.  
  890.  
  891. DESCRIPTION:
  892.  
  893.  
  894.       The  if  expression   allows   a   conditional   expression
  895.  
  896.       evaluation.  If the boolean expression is true the value of
  897.  
  898.       the if expression is the value of the expression  following
  899.  
  900.       the  word  THEN.   If  the  boolean expression is false the
  901.  
  902.       value of the if expression is the value of  the  expression
  903.  
  904.       following the word ELSE.
  905.  
  906.  
  907. EXAMPLE:
  908.  
  909.       WRITE( IF A > B THEN A ELSE B );
  910.  
  911.       A:= IF B=C THEN B ELSE D;
  912.  
  913.                                         label definition
  914.  
  915.  
  916. ELEMENT:
  917.  
  918.       label definition
  919.  
  920.  
  921.  
  922. FORMAT:
  923.  
  924.  
  925.       identifier|integer :
  926.  
  927.  
  928.  
  929. DESCRIPTION:
  930.  
  931.  
  932.       Label  definitions  are  optional  on   all   balanced   or
  933.  
  934.       unbalanced statements.
  935.  
  936.  
  937. EXAMPLE:
  938.  
  939.       FINISH:
  940.  
  941.       100:
  942.  
  943.                                         procedure call
  944.  
  945.  
  946. ELEMENT:
  947.  
  948.       procedure call
  949.  
  950.  
  951.  
  952. FORMAT:
  953.  
  954.  
  955.       identifier {(expression {,expression} ...)}
  956.  
  957.  
  958.  
  959. DESCRIPTION:
  960.  
  961.  
  962.       Procedures  can  be  called  with  or  without  parameters.
  963.  
  964.       Parameter  passing  is  by value.  Procedures can be called
  965.  
  966.       recursively with no limit set as to the number of recursive
  967.  
  968.       calls.
  969.  
  970.  
  971. EXAMPLE:
  972.  
  973.       COMPUTE;
  974.  
  975.       COMPARE("AAA", WORD);
  976.  
  977.       COUNT(1, 2, 3);
  978.  
  979.                                         procedure declaration
  980.  
  981.  
  982. ELEMENT:
  983.  
  984.       procedure declaration
  985.  
  986.  
  987.  
  988. FORMAT:
  989.  
  990.  
  991.       PROCEDURE identifier {(identifier {,identifier} ...)}
  992.  
  993.       {declaration; ...} simple statement
  994.  
  995.  
  996.  
  997. DESCRIPTION:
  998.  
  999.  
  1000.       A procedure declaration may or may not include  parameters.
  1001.  
  1002.       If parameters are included they must be declared before the
  1003.  
  1004.       simple  statement  which  represents  the   body   of   the
  1005.  
  1006.       procedure.   Parameters  are  passed by value and may be of
  1007.  
  1008.       type integer, decimal or string.  Procedures do not  return
  1009.  
  1010.       a  value  to  the  point of call.  Procedures can be called
  1011.  
  1012.       recursively.  Procedures  are  considered  separate  blocks
  1013.  
  1014.       within which local variables may be declared.
  1015.  
  1016.  
  1017. EXAMPLE:
  1018.  
  1019.       PROCEDURE OUTPUT;
  1020.          WRITE ("HELLO");
  1021.  
  1022.       PROCEDURE COMPARE(X,Y);
  1023.          INTEGER X,Y;
  1024.          BEGIN
  1025.          WRITE("THE LARGEST INTEGER IS ");
  1026.          IF X > Y THEN
  1027.             WRITE(X);
  1028.          ELSE
  1029.             WRITE(Y);
  1030.          END;
  1031.  
  1032.                                         READ statement
  1033.  
  1034.  
  1035. ELEMENT:
  1036.  
  1037.       READ statement
  1038.  
  1039.  
  1040.  
  1041. FORMAT:
  1042.  
  1043.  
  1044.       READ {file identifier}(variable {,variable} ...) {ONENDFILE block}
  1045.  
  1046.  
  1047.  
  1048. DESCRIPTION:
  1049.  
  1050.  
  1051.       If the form of the READ statement is READ(,  then the input
  1052.  
  1053.       device  is  the  console.   Otherwise a file option must be
  1054.  
  1055.       specified and  the  input  device  is  the  disk.   A  READ
  1056.  
  1057.       statement  reads  one  or  more  variables  at a time.  The
  1058.  
  1059.       optional ONENDFILE section indicates  action  to  be  taken
  1060.  
  1061.       when the end of the specified file is reached.
  1062.  
  1063.  
  1064. EXAMPLE:
  1065.  
  1066.       READ(WORDONE, X, VALUE2);
  1067.  
  1068.       READ FILE3 (WORDONE, X, VALUE2);
  1069.  
  1070.  
  1071. PROGRAMMING NOTE:
  1072.  
  1073.  
  1074.       The ONENDFILE section is curently not implemented.
  1075.       The file identifier must have a CPM file name assigned
  1076.       to it prior to reading from that file.  When this file 
  1077.       name is assigned in an assignment statement it also
  1078.       opens the file.  All files are automatically closed
  1079.       at the end of the block in which they are declared.
  1080.       A file close error will occurr if a file is declared
  1081.       and never opened.
  1082.  
  1083.  
  1084.                                         reserved word list
  1085.  
  1086.  
  1087.  
  1088. ELEMENT:
  1089.  
  1090.  
  1091.       reserved word list
  1092.  
  1093.  
  1094.  
  1095. FORMAT:
  1096.  
  1097.  
  1098.       letter {letter} ...
  1099.  
  1100.  
  1101.  
  1102. DESCRIPTION:
  1103.  
  1104.  
  1105.       The following words are reserved by ALGOL-M and may not  be
  1106.  
  1107.       used as identifiers:
  1108.     AND        ARRAY        BEGIN        CASE
  1109.     CLOSE        DECIMAL        DO        ELSE
  1110.     END        FILE        FUNCTION    GO
  1111.     GOTO        IF        INTEGER        NOT
  1112.     OF        ONENDFILE    OR        PROCEDURE
  1113.     READ        STEP        STRING        TAB
  1114.     THEN        TO        UNTIL        WHILE
  1115.     WRITE        WRITEON
  1116.  
  1117.  
  1118.       Reserved words must be preceeded and followed by  either  a
  1119.  
  1120.       special  character  or a space.  Spaces may not be embedded
  1121.  
  1122.       within reserved words.
  1123.  
  1124.  
  1125.                                         simple statement
  1126.  
  1127.  
  1128.  
  1129. ELEMENT:
  1130.  
  1131.      simple statement
  1132.  
  1133.  
  1134.   FORMAT:
  1135.  
  1136.       block|assignment statement|for statement|
  1137.       case statement||goto statement|
  1138.       while statement|read statement|write statement|
  1139.       procedure call|identifier
  1140.  
  1141.  
  1142.  
  1143. DESCRIPTION:
  1144.  
  1145.  
  1146.       All ALGOL-M statements are free form and must be  
  1147.       separated by semicolons.
  1148.  
  1149.  
  1150.                                         simple declaration
  1151.  
  1152.  
  1153.  
  1154. ELEMENT:
  1155.  
  1156.  
  1157.       simple declaration
  1158.  
  1159.  
  1160.  
  1161. FORMAT:
  1162.  
  1163.  
  1164.       INTEGER|DECIMAL|STRING {(identifier|integer)}
  1165.  
  1166.       identifier {,identifier} ...
  1167.  
  1168.  
  1169.  
  1170. DESCRIPTION
  1171.  
  1172.       Simple integer variables may be any value  between  -16,383
  1173.  
  1174.       and  +16,383.  Simple decimal variables can be specified as
  1175.  
  1176.       any length from one to 18 digits with a default  length  of
  1177.  
  1178.       10 digits.  Simple string variables can be specified as any
  1179.       length from one to 255 characters with a default length  of
  1180.  
  1181.       10 characters.
  1182.  
  1183.  
  1184. EXAMPLE:
  1185.  
  1186.       INTEGER X;
  1187.  
  1188.       DECIMAL(15) X,Y;
  1189.  
  1190.       STRING(33) WORDONE, WORDTWO, WORDTHREE;
  1191.  
  1192.                                         special characters
  1193.  
  1194.  
  1195. ELEMENT
  1196.  
  1197.       special characters
  1198.  
  1199.  
  1200.  
  1201. DESCRIPTION:
  1202.  
  1203.  
  1204.       The following special characters are used by ALGOL-M:
  1205.  
  1206.            
  1207.  
  1208.               )       close parenthesis
  1209.  
  1210.               *       asterisk
  1211.  
  1212.               +       plus
  1213.  
  1214.               -      minus  
  1215.  
  1216.               :       colon
  1217.  
  1218.               ;       semicolon
  1219.  
  1220.               <       less-than
  1221.  
  1222.               >       greater-than
  1223.  
  1224.               =       equal
  1225.  
  1226.               ,       comma
  1227.  
  1228.               [       open bracket
  1229.  
  1230.               ]       close bracket
  1231.               :=      assigned equal
  1232.  
  1233.               **      exponentiation
  1234.  
  1235.               %       percentage
  1236.  
  1237.       Any special character in the ASCII character set may appear
  1238.  
  1239.       in  a string.  Special characters,  other than those listed
  1240.  
  1241.       above, will cause an error condition if used outside  of  a
  1242.  
  1243.       string.
  1244.  
  1245.  
  1246.                                         TAB expression
  1247.  
  1248.  
  1249.  
  1250. ELEMENT:
  1251.  
  1252.  
  1253.       TAB expression
  1254.  
  1255.  
  1256.  
  1257. FORMAT:
  1258.  
  1259.  
  1260.       TAB expression
  1261.  
  1262.  
  1263.  
  1264. DESCRIPTION:
  1265.  
  1266.  
  1267.       TAB is optionally  used  in  a  WRITE  statement  to  cause
  1268.  
  1269.       spacing  on  the  output  line.   The  amount of spacing is
  1270.  
  1271.       specified by the integer expression following TAB.
  1272.  
  1273.  
  1274. EXAMPLE:
  1275.  
  1276.       WRITE("NEXT NAME", TAB 5, NAME[I]);
  1277.  
  1278.                                         unbalanced statement
  1279.  
  1280.  
  1281. ELEMENT:
  1282.  
  1283.       unbalanced statement
  1284.  
  1285.  
  1286.  
  1287. FORMAT:
  1288.  
  1289.  
  1290. -      {label definition} IF boolean expression THEN statement
  1291.  
  1292.  
  1293.  
  1294.       {label definition} IF boolean expression THEN balanced
  1295.  
  1296.       statement ELSE unbalanced statement
  1297.  
  1298.  
  1299. DESCRIPTION:
  1300.  
  1301.  
  1302.       Unlike the balanced  statement  that  will  always  have  a
  1303.  
  1304.       balanced statement on either side of the ELSE in an IF THEN
  1305.  
  1306.       ELSE  structure,  an  unbalanced  statement  may  not  even
  1307.  
  1308.       include the ELSE portion of the statement.
  1309.  
  1310.  
  1311. EXAMPLE:
  1312.  
  1313.       IF S > Y THEN WRITE(X);
  1314.  
  1315.       IF X < Y THEN
  1316.          IF Z > Y THEN
  1317.             WRITE(Z)
  1318.          ELSE
  1319.             WRITE(X);
  1320.  
  1321.  
  1322. PROGRAMMING NOTE:
  1323.  
  1324.  
  1325.       A semicolon is not allowed after the statement  immediately
  1326.  
  1327.       preceding an ELSE.
  1328.  
  1329.  
  1330.                                         variable
  1331.  
  1332.  
  1333.  
  1334. ELEMENT:
  1335.  
  1336.  
  1337.       variable
  1338.  
  1339.  
  1340.  
  1341. FORMAT:
  1342.  
  1343.  
  1344.       identifier {[bound pair list]}
  1345.  
  1346.  
  1347.  
  1348. DESCRIPTION:
  1349.  
  1350.  
  1351.       A variable in ALGOL-M may be simple or subscripted  and  of
  1352.  
  1353.       type INTEGER, DECIMAL, or STRING.
  1354.  
  1355.  
  1356. EXAMPLE:
  1357.  
  1358.       X
  1359.  
  1360.       VALUE[2]
  1361.  
  1362.       Z[1,X * Y]
  1363.  
  1364.                                         WHILE statement
  1365.  
  1366.  
  1367. ELEMENT:
  1368.  
  1369.       WHILE statement
  1370.  
  1371.  
  1372.  
  1373. FORMAT:
  1374.  
  1375.  
  1376.       WHILE boolean expression DO simple statement
  1377.  
  1378.  
  1379.  
  1380. DESCRIPTION:
  1381.  
  1382.  
  1383.       WHILE statements continue executing  the  simple  statement
  1384.  
  1385.       following  the  DO for as long as the boolean expression is
  1386.  
  1387.       true.
  1388.  
  1389.  
  1390. EXAMPLE:
  1391.  
  1392.       WHILE I > 0 DO
  1393.             I := I - 1;
  1394.  
  1395.       WHILE X > 5 AND Y <> 8 DO
  1396.             BEGIN
  1397.               X := X / 3;
  1398.               WRITE(X);
  1399.             END;
  1400.  
  1401.                                         WRITE statement
  1402.  
  1403.  
  1404. ELEMENT:
  1405.  
  1406.       WRITE statement
  1407.  
  1408.  
  1409.  
  1410. FORMAT:
  1411.  
  1412.  
  1413.       WRITE|WRITEON {file option}
  1414.  
  1415.       (expression|tab expression|string
  1416.  
  1417.       {,expression|tab expression|pic definition|string} ...)
  1418.  
  1419.  
  1420.  
  1421. DESCRIPTION:
  1422.  
  1423.  
  1424.       The WRITE option indicates the output will  start  printing
  1425.  
  1426.       on  a  new  line,  while  the  WRITEON option will continue
  1427.  
  1428.       printing on the same line.  If the form of the statement is
  1429.  
  1430.       WRITE(  or  WRITEON(,  the  output  device  is the console.
  1431.  
  1432.       Otherwise, a file option must be specified and  the  output
  1433.  
  1434.       device is the disk.
  1435.  
  1436.  
  1437. EXAMPLE:
  1438.  
  1439.       WRITE(X);
  1440.  
  1441.       WRITE("THE NUMBER IS",X + Y);
  1442.  
  1443.       WRITE("ANSWER", TAB 5, X * Y);
  1444.       WRITE FILE("hello");
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.