BEGIN INDEX

BEGIN _ _ _ _ _ _ _ _ _ _ _ _ command

begin is used to start a block statement, which is closed with end.

syntax:

begin<statement>{; <statement>}* end

<statement> is any valid REDUCE statement.

examples:


begin for i := 1:3 do write i end; 


  1
  2
  3     


begin scalar n;n:=1;b:=for i:=1:4 product(x-i);return n end;
 


  1 


b; 

   4        3        2
  X   - 10*X   + 35*X   - 50*X  + 24

A begin...end block can do actions (such as write), but does not return a value unless instructed to by a return statement, which must be the last statement executed in the block. It is unnecessary to insert a semicolon before the end.

Local variables, if any, are declared in the first statement immediately after begin, and may be defined as scalar, integer, or real. array variables declared within a begin...end block are global in every case, and let statements have global effects. A let statement involving a formal parameter affects the calling parameter that corresponds to it. let statements involving local variables make global assignments, overwriting outside variables by the same name or creating them if they do not exist. You can use this feature to affect global variables from procedures, but be careful that you do not do it inadvertently.