[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Pascal for OpenVMS
Language Reference Manual


Previous Contents Index

10.2.4 AT

The AT attribute specifies that HP Pascal allocates no storage for the object (storage has already been allocated) and that it resides at the exact, specified address.


AT( n )

The exact address is specified by the constant expression n. Variables representing machine-dependent entities are frequently given the AT attribute.

Usage and Default Information:

  • A variable having the AT, COMMON, or PSECT attribute is implicitly static.
  • AT cannot be applied to routines or to compilation units.
  • AT cannot be applied to variables of nonstatic types.

For More Information:

  • On default allocation for variables declared in the outermost block of a program or in nested blocks ( Section 10.2.5)
  • On default allocation for variables declared in the outermost block of a module ( Section 10.2.36)
  • On static and nonstatic types ( Section 2.9)

10.2.5 AUTOMATIC

The AUTOMATIC attribute specifies that storage for the variable be allocated each time the program enters the routine in which the variable is declared. The storage is deallocated each time the program exits from that routine. An automatic variable exists as long as the declaring routine remains active.

Usage and Default Information:

  • By default, variables declared in nested blocks are automatic.
  • By default, variables declared at the outermost level of a program are automatic, though for efficiency they can be made static.
  • By default, the control part of the nonstatic types and the pointer part of variables of nonstatic types follow the same rules as regular variables: they are static or automatic depending on the location of the declaration and the usage of the data.
  • Global and external variables are implicitly static. Thus, they conflict with the AUTOMATIC attribute.
  • Program-level variables with the AUTOMATIC attribute are not recorded in environment files.
  • AUTOMATIC cannot be applied to routines and compilation units.
  • AUTOMATIC cannot be applied to nonstatic types.

For More Information:

10.2.6 BIT

The BIT attribute specifies the amount of storage in bits to be received by the object.


BIT[[( n )]]

The optional constant n indicates the number of bit storage units.

Usage and Default Information:

The following size attribute restrictions apply to BIT, BYTE, LONG, WORD, QUAD and OCTA.

  • The default size of an object depends on its type.
  • The constant expression n must denote a positive integer. If you omit n, the default value is 1.
  • Objects of floating-point or pointer types must have a size equal to their allocation size.
  • Ordinal types cannot exceed their maximum size, which is determined by the platform and the value of the data switch for the compile command.
  • The amount of storage described must be large enough to contain an object of the specified type; otherwise, a compile-time error occurs.
  • Assignment to variables with a size attribute are zero-extended (if necessary) and all bits are written.
  • When you fetch from variables with a size attribute, the compiler need only reference sufficient bits to access the legal value of the type. The contents of a variable are undefined if it does not contain a zero-extended legal value of the variable's type.
  • A size attribute is illegal on a conformant parameter, on a component of a VARYING string, on an object of a structured type having a file component, or on a nonstatic type. In an array variable passed to a conformant formal parameter, size and alignment attributes are illegal on all dimensions of the actual parameter, except the first, that correspond to the dimensions of the formal parameter.
  • Two variables of the same type that have different allocation sizes are assignment compatible but are not structurally compatible.

For More Information:

10.2.7 BYTE

The BYTE attribute specifies the amount of storage in bytes to be received by the object.


BYTE [[( n )]]

The optional constant n indicates the number of byte storage units.

For More Information:

10.2.8 CHECK

The CHECK attribute specifies error-checking options that are to be enabled during program execution.


CHECK [[( {identifier},... )]]

An identifier specifies an option to be enabled. If you omit the list of options, all available positive options are enabled.

Table 10-2 presents the options that allow you to choose which aspects of a program should be checked. The negations of an option disable checking for that option.

Table 10-2 Summary of Checking Options
Option Action Negation
ALL Enables all forms of checking. NONE
BOUNDS Verifies that an index expression is within the bounds of an array's index type and that character-string sizes are compatible with the operations being performed and that schema types are compatible. NOBOUNDS
CASE_SELECTORS Verifies that the value of a case selector is contained in the corresponding case label list. NOCASE_SELECTORS
DECLARATIONS Verifies that schema definitions yield valid types and that uses of GOTO from one block to an enclosing block are correct. NODECLARATIONS
OVERFLOW Verifies that the result of an integer computation does not exceed the machine representation. NOOVERFLOW
POINTERS Verifies that the value of a pointer variable is not NIL. NOPOINTERS
SUBRANGE Verifies that values assigned to variables of subrange types are within the subrange; verifies that a set expression is assignment compatible with a set variable. NOSUBRANGE

Usage and Default Information:

  • This attribute can be applied to routines and compilation units.
  • If not specified on a routine, or compilation unit, the CHECK qualifier or switch value is used as the default. If you specify options for CHECK, HP Pascal enables only the specified options. Consider the following example:


    
    [CHECK]            { is equivalent to }   [CHECK( ALL )]
    [CHECK( option )]  { is equivalent to }   [CHECK( NONE, option )]
    
    

Consider the following example:



PROGRAM Check_Features;

[CHECK( POINTERS, CASE_SELECTORS )] PROCEDURE Linked_List
    (VAR Client : Info_Rec);   {Body of the procedure...}

[CHECK( OVERFLOW )] FUNCTION Integer_Compute
    (VAR Int1, Int2, Int3 : INTEGER) : INTEGER;
    {Body of the function...}

PROCEDURE Bounds_Check (VAR A_String : VARYING[30] OF CHAR;
                        VAR Char_Array : ARRAY[1..25] OF CHAR;
                        VAR Half_Alpha : 'A'..'M');  {Body...}

For the routines Linked_List and Integer_Compute, HP Pascal enables only the specified options. The procedure Bounds_Check has only the BOUNDS, and DECLARATIONS options enabled by default (unless you use a compilation switch to override the default).

For More Information:

On type compatibility ( Section 2.10)

10.2.9 CLASS_A

The CLASS_A attribute causes a formal parameter to be passed by an array descriptor that describes contiguous arrays of atomic data types or contiguous arrays of fixed-length strings. This attribute is illegal on parameters of schema types.

Consider the following example:



PROCEDURE Test2( P3 : [CLASS_S] PACKED ARRAY[L..U : INTEGER] OF CHAR;
                 P4 : [CLASS_A] ARRAY[L2..U2 : INTEGER] OF REAL); EXTERN;

This example defines a procedure Test2, which has two parameters. The first parameter, P3, is passed by descriptor of CLASS_S. The second parameter, P4, is passed by a CLASS_A descriptor.

For More Information:

  • On HP Pascal parameter defaults ( Section 6.3)
  • On CLASS_A descriptors (HP OpenVMS Calling Standard)

10.2.10 CLASS_NCA

The CLASS_NCA attribute causes a formal parameter to be passed by a noncontiguous array descriptor. This attribute is illegal on parameters of schema types.

For More Information:

  • On HP Pascal parameter defaults ( Section 6.3)
  • On CLASS_NCA descriptors (HP OpenVMS Calling Standard)

10.2.11 CLASS_S

The CLASS_S attribute causes a formal parameter to be passed by a single descriptor form that is used for scalar data and fixed-length strings. On OpenVMS systems, this attribute allows routines written in HP Pascal to accept actual parameters from languages such as FORTRAN that generate CLASS_S descriptors.

Usage and Default Information:

  • In order to pass a CLASS_S string descriptor, you must use a packed conformant array of characters.
  • This attribute is illegal on parameters of schema types.
  • When the packed conformant array is passed by CLASS_S descriptor, the lower bound of the conformant schema is always 1 and the upper bound of the conformant schema is the length of the string being passed.

Consider the following example:



PROCEDURE Print_String( String_Parm :
          [CLASS_S] PACKED ARRAY[LOW..HIGH : INTEGER] OF CHAR );
BEGIN
   WRITELN( 'The CLASS_S string is', String_Parm );
   WRITELN( 'The lowerbound is', Low );
   WRITELN( 'The upperbound is', High );
END;

The previous example defines the procedure Print_String, which has one parameter. The CLASS_S attribute on the HP Pascal routine specifies that the calling routine passes the String_Parm parameter by a CLASS_S descriptor.

For More Information:

  • On HP Pascal parameter defaults ( Section 6.3)
  • On mixed-language programming (HP Pascal for OpenVMS User Manual)
  • On CLASS_A and CLASS_S descriptors (HP OpenVMS Calling Standard)

10.2.12 COMMON

The COMMON attribute specifies that storage for a variable be allocated in an overlaid program section called a common block.


   [ COMMON [[ ( { identifier } ) ]] ]

identifier

An identifier that indicates the name of the common block. If you omit the identifier, the name of the variable is used as the name of the common block.

This attribute allows you to share variables with other HP languages, such as HP Fortran.

Usage and Default Information:

  • A variable having the AT, COMMON, or PSECT attribute is implicitly static.
  • The COMMON attribute can be applied only to variables.
  • Only one variable can be allocated in a particular common block. Therefore, the name of the common block cannot be used as the name of another common block or program section.
  • If an HP Pascal program shares a record variable with a FORTRAN program, the fields must be laid out identically in both common blocks.
  • Variables declared with the COMMON attribute are longword aligned by default for compatibility with other HP languages.

For More Information:

  • On default allocation for variables declared in the outermost block of a program or in nested blocks ( Section 10.2.5)
  • On default allocation for variables declared in the outermost block of a module ( Section 10.2.36)
  • On environment-specific information on common blocks (Appendix A)

10.2.13 ENUMERATION_SIZE

The ENUMERATION_SIZE attribute controls the allocation size of unpacked enumerated types and Booleans, which are considered enumerated types containing two elements. The ENUMERATION_SIZE attribute can be used on compilation units, TYPE sections, and VAR sections. When used before a TYPE or VAR section, the allocation size for enumerated types is modified only for the duration of the TYPE or VAR section. Note that specifying the ENUMERATION_SIZE attribute overrides any value that you previously specified with the /ENUMERATION_SIZE qualifier.

The ENUMERATION_SIZE attribute has the following format:


[ENUMERATION_SIZE(keyword)]

For example:


[ENUMERATION_SIZE(Byte))]
TYPE
   enum  = (red, blue, green)
   enum2 = (circle, square, triangle);
Table 10-3 lists the keywords for the ENUMERATION_SIZE attributes.

.

Table 10-3 ENUMERATION_SIZE Attribute Keywords
Keyword Description Default on
BYTE Allocates unpacked enumerated types with fewer than 255 elements and Booleans in a 8-bit byte. Otherwise, the enumerated types are allocated in a 16-bit word. OpenVMS VAX systems
LONG Allocates all unpacked enumerated types and Booleans in a 32-bit longword. OpenVMS I64 and
OpenVMS Alpha systems

10.2.14 ENVIRONMENT

You can apply the ENVIRONMENT attribute to compilation units, which causes the unit's program or module-level declarations and definitions to be saved.


ENVIRONMENT [[( name-string )]]

If the name string is omitted, the name of the source file is used as the environment file name.

The declarations and definitions made at the outermost level of the compilation unit (provided they do not have the AUTOMATIC or HIDDEN attribute) are saved in a newly created environment file. If the name string is specified, you must include a legal file specification.

Usage and Default Information:

  • There is a default file type of .PEN for environment files if a file name is specified.
  • If you do not specify a file name with the [ENVIRONMENT] attribute, then the file name of the source file is used with a .PEN extension for the name of the environment file. For example:


        {
          Module share_data.pas
        }
        [ENVIRONMENT]
        Module Share_Data;
          CONST
            Rate_For_Q1  = 0.1211;
            Rate_For_Q2  = 0.1156;
        END.
    

    The above module, when compiled, would result in the creation of an environment file named "share_data.pen."
  • The ENVIRONMENT attribute can not be specified on a program that declares nonstatic types or variables of nonstatic types at the outermost level.
  • The ENVIRONMENT attribute can be specified on a module that declares nonstatic types or variables of nonstatic types at the outermost level.
  • Programs and modules can access definitions and declarations in a created environment file by using the INHERIT attribute.

For More Information:

  • On name-string syntax ( Section 10.1)
  • On static and nonstatic types ( Section 2.9)
  • On programs and modules ( Section 7.4)
  • On examples of separate compilation (HP Pascal for OpenVMS User Manual)

10.2.15 EXTERNAL

The EXTERNAL attribute indicates a variable or routine that is assumed to be global in another independently compiled unit.


                         {identifier        }
         [ EXTERNAL [[ ( {'string-literal'  } ) ]] ]
                         {                  }

identifier

Identifier passed to the linker. It is passed in uppercase. If you omit the identifier, the name of the variable is used as the name of the common block.

string-literal

Passes the specified string-literal to the linker unmodified.

If you specify an identifier with EXTERNAL, HP Pascal supplies that name, rather than the identifier being declared, to the linker.

Usage and Default Information:

  • The names available to the linker for corresponding global and external variables and routines must be identical.
  • Global and external variables are implicitly static. Thus, they conflict with the AUTOMATIC attribute.
  • Compilation units cannot have the EXTERNAL or WEAK_EXTERNAL attribute.
  • By default, global and external routines have the characteristics of unbound routines.
  • External routines must be followed by the directive EXTERN, EXTERNAL, or FORTRAN when they are declared.

Consider the following example:



PROGRAM Freshman_Class;

[GLOBAL( Sort_Students )]
PROCEDURE Class_List( VAR Register_List, Sorted_List : Student_Rec );
{Procedure body...}

{In another compilation unit:}
MODULE Senior_Class;

[EXTERNAL( Sort_Students )]
PROCEDURE Roll_Call( VAR Start_List, End_List : Senior_Rec ); EXTERNAL;

This example shows the global declaration of a procedure with the name Sort_Students and an external reference to the same procedure in a different compilation unit.

For More Information:


Previous Next Contents Index