Page 145 - Standard Handbook Of Petroleum & Natural Gas Engineering
P. 145

130    Mathematics

                      Iterative  statements control  how  many  times  a  simple statement  or  a  com-
                    pound  statement is  repeated,  and also may  be nested  with  conditional  and/or
                    other iterative  statements. They  may  be
                      WHILE boolean  expression  DO
                        statement

                    or
                      REPEAT
                        statement
                      UNTIL boolean  expression

                    or
                      FOR variable:  = expression TO expression  DO
                         statement

                    where  the variable  and expressions must be  of  ordinal  (not real)  type  and TO
                    may be replaced by  DOWNTO. In all types of iterative constructions,  statement
                    may  refer  to  a  simple  statement  or  to  a  compound  statement  introduced  by
                    BEGIN  and completed  with  END,  for  example,

                      WHILE  NOT EOF DO
                         BEGIN
                           I:  = 0;
                           REPEAT
                             I:  = I  +  1;
                             READ(TEMP( I))
                           UNTIL  I  >  MAXI
                         END;
                       FOR  I:  = MAXI  DOWNTO  MINI  DO
                         BEGIN
                           X(1): = FNC(X(1 - 1) *  ABS(Z);
                           IF X(1) >  XFT THEN AGSTP(X(I),I,PTP(I))
                         END;
                       Subprogram statements-Used  to transfer  control between program units-the
                     main program, functions,  and procedures. A function call  is  the invocation  of  a
                     function  name in an assignment  statement, such as
                       X:  = DEF(Y)*Z;
                     which  will  transfer  control  to  DEF  and  pass  the  variable  Y  to  that  function.
                     Control returns  to  the calling unit  when  the END  statement of  the function is
                     encountered.  Intrinsic functions, supplied in the system library, are called in the
                     same manner.  (See Table  1-30 for a list  of  standard  Pascal  intrinsic functions.)
                     A procedure  call  is  made by  stating the name of the procedure  and the variables
                     to be passed,  e.g.,
                       CALCPRSSR( PIPENUM,TEMP,FFACTR);
                    will  transfer  control  to  procedure  CALCPRSSR.  Control  returns  to  the calling
                     unit when  the procedure END  statement is  found.
   140   141   142   143   144   145   146   147   148   149   150