[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP Pascal for OpenVMS
|
Previous | Contents | Index |
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.
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:
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 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.
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.
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:
[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).
On type compatibility ( Section 2.10)
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:
10.2.9 CLASS_A
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.
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.
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:
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.
The COMMON attribute specifies that storage for a variable be allocated in an overlaid program section called a common block.
[ COMMON [[ ( { 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.identifier
This attribute allows you to share variables with other HP languages, such as HP Fortran.
Usage and Default Information:
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:
Table 10-3 lists the keywords for the ENUMERATION_SIZE attributes.
[ENUMERATION_SIZE(Byte))]
TYPE
enum = (red, blue, green)
enum2 = (circle, square, triangle);
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 |
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:
{ Module share_data.pas } [ENVIRONMENT] Module Share_Data; CONST Rate_For_Q1 = 0.1211; Rate_For_Q2 = 0.1156; END. |
The EXTERNAL attribute indicates a variable or routine that is assumed to be global in another independently compiled unit.
{identifier } [ EXTERNAL [[ ( {'string-literal' } ) ]] ] { } |
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.identifier
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:
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.
Previous | Next | Contents | Index |