[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP Pascal for OpenVMS
|
Previous | Contents | Index |
The FLOAT attribute selects the default format for REAL and DOUBLE data types. The FLOAT attribute has the following format:
[FLOAT(keyword)] |
The GLOBAL attribute provides a strong definition of a variable or routine so that other independently compiled units can refer to it.
{identifier } [ GLOBAL [[ ( {'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
Usage and Default Information:
The HIDDEN attribute prevents information concerning a constant definition or a type, variable, procedure, or function declaration from being included in a generated environment file. You can only use the HIDDEN attribute on objects at the outermost level of the compilation unit.
It is possible to prevent all declarations within a declaration section from being included in the environment file by preceding the reserved word CONST, TYPE, or VAR with the HIDDEN attribute.
You can use the IDENT attribute to qualify the name of a compilation unit. In the absence of an IDENT attribute, the string '01' is supplied to the linker.
IDENT( name-string ) |
The name-string can contain additional information whose use is
implementation specific. The HP Pascal compiler uses this string
to supply identification information to the linker.
Consider the following example:
[IDENT( '100.5' ),ENVIRONMENT( 'sample.pen' )] MODULE SAMPLE; |
In this example, the IDENT string '100.5' is supplied to the linker.
The IMMEDIATE attribute causes a formal parameter value in a routine declaration to be passed by immediate value. This attribute can be used on scalar and floating-point parameters that are passed by immediate value. On OpenVMS I64 and OpenVMS Alpha systems, the parameter must be 64 bits or smaller. On OpenVMS VAX systems, the parameter must be 32 bits or smaller.
The IMMEDIATE attribute is not allowed on formal parameters of schema types. |
The INHERIT attribute indicates the environment file or files to be inherited by a compilation unit. The environment files specified by the INHERIT attribute must already have been created in compilation units (by either the ENVIRONMENT attribute or a compilation switch).
The compilation unit inherits one or more environment files named by the file specifications in the name strings.
INHERIT( {name-string},... ) |
Usage and Default Information:
There is a default file type of .PEN for inherited environment files.
For example:
When the preceding program is compiled, the compiler first attempts to
open the file 'share_data' as an environment file. If 'share_data' is
not found the compiler attempts to open 'share_data.pen' as an
environment file. If 'share_data.pen' is not found an error message is
issued and the compilation is stopped.
{
Program inherit_example.pas
}
[INHERIT ('share_data')]
Program inherit_example(output);
CONST
My_Rate = Rate_For_Q1*2.0;
BEGIN
Writeln(My_Rate)
END.
You can apply the INITIALIZE attribute to procedures to indicate that the procedure is to be called before the main program is entered. A compilation unit might include any number of INITIALIZE procedures, all of which are called in an unspecified order before the main program is entered.
Usage and Default Information:
Consider the following example:
PROGRAM Routine_Activate; [INITIALIZE] PROCEDURE Check_Open; {Procedure body...} {In the executable section:} BEGIN {HP Pascal activates Check_Open} {Body of program...} |
In this example, the body of the INITIALIZE procedure Check_Open is executed before the main program is activated.
You can apply the KEY attribute to record fields to indicate that the field is to be used as a key field when the record is part of an indexed file.
{n [[, {options},... ]] } KEY [[( {{options},... } )]] { } |
n
The parameter n represents the key number. A key number of 0 indicates that the field is the primary key of the record. All other key numbers indicate alternate keys. The key number must be a constant expression that denotes an integer value in the range from 0 through 254.
Table 10-4 lists the possible KEY attribute options.
Option | Action | Negation |
---|---|---|
ASCENDING | Specifies an ascending collating sequence | DESCENDING |
CHANGES | Specifies that changes can be performed on the key | NOCHANGES |
DUPLICATES | Specifies that duplicates of the key are allowed | NODUPLICATES |
Usage and Default Information:
Consider the following example:
TYPE Register = RECORD Student_No : [KEY( 0, DESCENDING )] INTEGER; Student_Name : RECORD Last_Name : PACKED ARRAY[1..20] OF CHAR; First_Name : PACKED ARRAY[1..15] OF CHAR; Initial : CHAR; END; Course_Load : INTEGER; Grade_Average : REAL; Class : [KEY( 1 )] PACKED ARRAY[1..9] OF CHAR; END; |
This example defines the identifier Register to denote a record type. The first field, Student_No is the primary key of the record. It has been defined as a DESCENDING, NOCHANGES, and NODUPLICATES key. Register contains another field, Class, which is established as the alternate ASCENDING, CHANGES, and DUPLICATES key.
You can apply the LIST attribute to a formal parameter of a routine and indicates that the routine can be called with multiple actual parameters that correspond to the last formal parameter named in the routine heading.
You can also use the ARGUMENT and ARGUMENT_LIST_LENGTH predeclared routines when writing procedures and functions that use the LIST attribute.
Usage and Default Information:
PROCEDURE Foo( PROCEDURE q( x : [LIST] CHAR ) ); |
PROCEDURE Bar( x : [LIST] CHAR ); |
Foo( Bar ); |
For example, the function Average demonstrates the use of the LIST attribute, which allows any number of like expressions to be passed to a function:
PROGRAM Use_List(OUTPUT); FUNCTION Average ( P: [list] INTEGER): REAL; VAR SUM: REAL VALUE 0.0; I: INTEGER; BEGIN FOR I:= 1 TO ARGUMENT_LIST_LENGTH(P) DO SUM:= SUM + ARGUMENT (P,I); AVERAGE:= SUM/ARGUMENT_LIST_LENGTH(P); END; BEGIN WRITELN(AVERAGE(3,6,9),AVERAGE(10,3,4,17)); END. |
The LOCAL attribute indicates that an object is unavailable to other independently compiled units.
Usage and Default Information:
The LONG attribute specifies the amount of storage in longwords to be received by the object.
LONG [[( n )]] |
The optional constant n indicates the number of longword storage units.
Consider the following example:
PROGRAM Size; TYPE Status = [LONG] BOOLEAN; VAR Return_Status : Status; FUNCTION Example( Param1, Param2 : INTEGER ) : Status; EXTERNAL; {Function body...} |
The program Size defines a BOOLEAN type Status and declares a variable Return_Status of this type. So, the result type of the function is declared to have a size of one longword. The machine code that references the result type can not copy the entire longword, however, if the default size for a Boolean is less than a longword.
The NOOPTIMIZE attribute prohibits the compiler from optimizing code for the compilation unit or routine. The NOOPTIMIZE attribute can only be applied to routines on OpenVMS VAX systems.
On OpenVMS VAX systems, the NOOPTIMIZE attribute guarantees left-to-right evaluation order with full evaluation of both operands of the AND and OR Boolean operators to aid in diagnosing all potential programming errors. On OpenVMS I64 and OpenVMS Alpha systems, NOOPTIMIZE only guarantees full evaluation.
If you wish to have short circuit evaluation even with the NOOPTIMIZE attribute, then use the AND_THEN and OR_ELSE Boolean operators.
The OCTA attribute specifies the amount of storage in octawords to be received by the object.
OCTA [[( n )]] |
The optional constant n indicates the number of octaword storage units.
The OPTIMIZE attribute specifies optimization options that are to be enabled during compilation of a compilation unit or routine.
OPTIMIZE [[( {identifier},... )]] |
The options listed with the OPTIMIZE attribute are enabled. The
negation of an option disables that optimization. The valid options are
ALL, NONE, INLINE, NOINLINE. Table 10-5 lists the options.
Option | Action |
---|---|
[OPTIMIZE],
[OPTIMIZE(ALL)] |
Enables all optimization components. Inline expansion of user-defined routines is enabled in automatic selection mode. |
[OPTIMIZE(NOINLINE)] | Disables inline expansion for user-defined routines. All other optimization components are enabled or disabled according to the command line or the setting of the OPTIMIZE attribute on an enclosing scope routine. |
[OPTIMIZE(INLINE)] | Enables preferential inline expansion of user-defined routines. All other optimization components are enabled/disabled according to the command line on an enclosing scope routine. |
[OPTIMIZE(ALL,NOINLINE)] | Enables all optimization components, disables inline expansion for user-defined routines. |
[OPTIMIZE(NONE,INLINE)] | Disables all optimization components, enables inline expansion of user-defined routines. |
[NOOPTIMIZE],[OPTIMIZE(NONE)] | Disables all optimization components, disables inline expansion of user-defined routines. |
Usage and Default Information:
Usage and Default Information on OpenVMS I64 and OpenVMS Alpha systems only:
Usage and Default Information on OpenVMS VAX systems only:
Previous | Next | Contents | Index |