[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
const                    Starts a Set of Constant Declarations

 const
   <cname>     = <value>;
   <cname>     = <value>;
   ...

    The CONST keyword precedes a list of constant declarations. A constant
    is just a named value. Anywhere you use <cname> in your program, the
    compiler substitutes <value>. This means that you cannot assign a new
    value to <cname> or use it as a pass-by-address parameter to a
    procedure or function. Constants declared in a procedure or function
    are local to that procedure or function. Those declared in the main
    program are global from the point of their declaration to the end of
    the program.

            <cname>   the name of the constant.

            <value>   the constant's value; can be Integer, Real, Char,
                      Boolean, or String; Turbo Pascal will also allow
                      previously declared enumerated types.

    In Standard Pascal, you can have at most one CONST section per program
    or subprogram (procedure, function), and it must appear after the
    LABEL section and before the TYPE section. Turbo Pascal allows you to
    have multiple CONST sections per program or subprogram and only
    requires that they appear before (and outside of) the main body of
    that program or subprogram.

    Turbo Pascal also allows you to declared "typed constants" in the
    CONST sections. Typed constants are pre-initialized variables, such as
    TRUE.

  -------------------------------- Example ---------------------------------

           const
             Limit = 100;
             Yes   = True;
             No    = False;
             Blank = ' ';
             e     = 2.7182871825;

See Also: type var procedure program typed constants
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson