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

126    Mathematics

                     Constant  declaration-Must  precede variable declarations  and be of the form
                     CONST
                       constant name  = value;
                       constant  name  = value;
                       etc.
                   For  example,

                     CONST
                                  PI  = 3.1415927;
                               FACT  = TRUE;
                           PIPENUM  = 27;
                          MINDPTH  =  1500;
                          MAXDPTH  = 7500.0;
                          CLRRADS  = .34;

                      Type declaration-Must  be placed  after CONST sequence and before  variable
                    declarations;  used  to  define  new  (not predefined)  data types  either  as  a  range
                    of values or as specific values within  parentheses  and to define arrays, records,
                    and  files.  User-defined  scalar  types  are  ordered  in  increasing  left  to  right
                    sequence.  For  example,

                      TYPE
                           UNIT  = (PIPE,COLLAR,MOTOR);
                          TEMP  = ARRAY[1..34  OF REAL;
                            ATP  = ARRAY[1..50,1..10]  OF CHAR;
                           PREC  = RECORD
                                        TIME:  REAL;
                                         RUN:  INTEGER;
                                      CRUNIT:  UNIT;
                                       PRSSR:  REAL;
                                  END;
                      STACKPTR  = TSTACKELEMENT;
                        STRING  = PACKED  ARRAY[ l..MAXLENGTH  OF CHAR;
                                    (* may  be predefined  on some systems  *)
                         TSURF  = 0.30;
                           CSET  = SET OF 'A'..'Z';
                          NODE  =  l..PIPENUM:

                      Variable  declaration-Placed  after  TYPE  statements  and defines  the  type  of
                    each  variable,  array,  and  record  used  in  the program  unit,  for  example

                       NXTUNIT:  NODE;
                            LOG:  PREC;
                         COUNT  INTEGER;
                          PTEMP:  TEMP;
                      PREVTEMP:  TEMP;
                         LETTER:  CSET;
                          NAME:  ARRAY[l..PO]  OF CHAR;
                           RUNS:  FILE  OF PREC;
                      BEGIN-Introduces  the executable  statements  in  each  block  of  statements.
   136   137   138   139   140   141   142   143   144   145   146