[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Pascal for OpenVMS
Language Reference Manual


Previous Contents Index

8.40 HALT Procedure

The HALT procedure uses operating system resources to stop execution of your program unless you have written a condition handler (using the ESTABLISH procedure) that enables continued execution.

For More Information:

8.41 HEX Function

The HEX function returns a character-string value that is the hexadecimal equivalent of the specified parameter. The return value is compatible with all other string types.


HEX( x[[, length[[, digits]] ]] )

The parameter x is the expression to be converted. This parameter must have a size that is known at compile time; it cannot be VARYING OF CHAR, a conformant parameter, or a schema type.

Two optional integer parameters specify the length of the resulting string and the minimum number of significant digits to be returned. If you specify a length that is too short to hold the converted value, the resulting string is truncated on the left. If you do not specify values for the optional parameters, a default length and a default number of significant digits is used. By default, the number of significant digits is the minimum number of characters necessary to express all the bits of the converted parameter. This default length is one character more than the default number of digits, which causes a leading blank to be included in the resulting string when both parameters are omitted. Consider the following example:



VAR
   p : ^Rec;
{In the executable section:}
Digits := 8;
NEW( p );
Result := HEX( p, 10, Digits );

In this example, the HEX function returns a string of 10 characters containing the hexadecimal equivalent of the value of the pointer variable p. The string has eight significant digits, as specified by the value of the actual parameter Digits.

8.42 IADDRESS Function

The IADDRESS function returns an INTEGER_ADDRESS value that refers to the address of either a constant or VOLATILE variable, or parameter, or a routine. IADDRESS does not generate compile-time warnings about volatility (as does the ADDRESS function). The IADDRESS function is commonly used for constructing arguments for system services of the OpenVMS operating system.


IADDRESS( x )

The parameter x can be of any type except a component of a packed structured type.

Note

The HP Pascal compiler automatically assumes that all pointers refer either to dynamic variables allocated by the NEW procedure or to variables that have the VOLATILE attribute. You, therefore, should use utmost caution when using the IADDRESS function. This function does not generate compile-time warnings about volatility.

Consider the following example:



VAR
   Real_Addr : INTEGER_ADDRESS;
   Real_Var  : [VOLATILE] REAL;
{In the executable section:}
Real_Addr := IADDRESS( Real_Var );  {Returns address of Real_Var}
WRITELN( 'The address of Real_Var is', Real_Addr );

For More Information:

8.43 IADDRESS64 Function

The IADDRESS64 function returns an INTEGER64 value that refers to the address of either a constant or VOLATILE variable, or parameter, or a routine. The IADDRESS64 function is otherwise identical to the IADDRESS function.


IADDRESS64( x )

The parameter x can be of any type except a component of a packed structured type.

For More Information:

8.44 IN_RANGE Function

The IN_RANGE function determines if a value is in the defined subrange.


IN_RANGE(expression,lower-expression,upper-expression)

The parameters must be expressions of the same ordinal type. The function returns TRUE if x has a value that is in the range specified by lower-expression and upper_expression; otherwise, the function returns FALSE.

8.45 INDEX Function

The INDEX function searches a string for a specified substring and returns an integer value that either indicates the location of the substring or the status of the search.


INDEX( string, substring )

INDEX requires two character-string expressions as parameters: a string to be searched and a substring to be found.

The search ends as soon as the first occurrence of the substring is located:

  • If the substring is found, INDEX returns the string component that contains the first letter of the substring.
  • If the substring is not found, INDEX returns the value 0.
  • If the substring is an empty string, INDEX returns the value 1.
  • If the string to be searched is an empty string, INDEX returns the value 0 unless the substring is also empty, in which case, INDEX returns the value 1.
  • If the substring is found, it does not return the string component but the index (such as subscript) of the component.

Consider the following example:


The_String := 'The Pilgrims landed at Plymouth Rock';
Substring  := 'Plymouth Rock';
Position   := INDEX( The_String, Substring ); {Returns 24}
Substring  := 'Mayflower';
Position   := INDEX( The_String, Substring ); {Returns 0}

For More Information:

8.46 INT Function

The INT function converts the parameter and returns its INTEGER equivalent.


INT( x )

The parameter x must be of an ordinal type.

Overflow can occur and is detected at runtime if overflow checking is enabled and the value of x is outside the range of INTEGER.

8.47 INT64 Function

The INT64 function converts the parameter and returns its INTEGER64 equivalent.


INT64(x)

The parameter x must be of an ordinal type.

Overflow can occur and is detected at run time if overflow checking is enabled and the value of x is outside the range of INTEGER64.

8.48 LE Function

The LE function returns a Boolean value that specifies if the first parameter is less than or equal to the second parameter, according to the ASCII values of the strings' characters.


LE( str1, str2 )

The parameters str1 and str2 must be character-string expressions. HP Pascal does not pad shorter strings with blanks.

The expression LE( Str1, Str2 ) is equivalent to the following:


( LENGTH( Str1 ) < LENGTH( Str2 ) )  OR  ( Str1 <= Str2 )

Consider the following example:


VAR
   Match : BOOLEAN;
   Test  : STRING( 8 ) VALUE 'ENTRANCE';
{In the executable section:}
Match := LE( 'exit', 'exit' );   {Returns TRUE}
Match := LE( Test, 'EXIT' );     {'N' less-than 'X': Returns TRUE}

For More Information:

8.49 LENGTH Function

The LENGTH function returns an integer value that is the length of a specified string expression.


LENGTH( str )

The str parameter must be a character-string expression.

For More Information:

8.50 LN Function

The LN function returns a real value that represents the natural logarithm of the specified parameter.


LN( x )

The parameter x can be an integer or REAL type. The value of x must be greater than zero.

8.51 LOWER Function

The LOWER function returns the lower bound for ordinal types, SET base types, and array indexes.


LOWER( x [[, n]] )

The parameter x is a type identifier or variable of an ordinal, SET, or ARRAY type. The parameter n is an integer constant that denotes a dimension of x, if x is an array. If x is an array and if you omit the parameter n, HP Pascal uses the default value 1. If x is an array, LOWER returns the lower bound of the nth dimension of x. If x is an ordinal type, LOWER returns the lower bound or smallest value. If x is a SET, LOWER returns the lower bound of the SET base type.

For More Information:

8.52 LSHIFT Function

The LSHIFT predeclared function returns a value of the same type as its first parameter. The return value represents the value of the first parameter after the bits have been shifted to the left.


LSHIFT(expression,expression) )

The parameters are two integer or unsigned values. The first parameter represents a value to shift; the second represents the number of bits to shift the first value to the left. LSHIFT inserts zero bits on the right as the bits shift left.

Note that shifting integers is not equivalent to multiplying or dividing by a power of two when the value of the integer is negative.

If the number of bits shifted is larger than the natural integer size of the target platform, the result is undefined.

For More Information:

8.53 LT Function

The LT function returns a Boolean value that specifies if the first parameter is less than the second parameter, according to the ASCII values of the strings' characters.


LT( str1, str2 )

The parameters str1 and str2 must be character-string expressions. HP Pascal does not pad shorter strings with blanks. Consider the following example:


VAR
   Match : BOOLEAN;
   Test  : STRING( 8 ) VALUE 'ENTRANCE';
{In the executable section:}
Match := LT( 'exit', 'exit' );   {Returns FALSE}
Match := LT( Test, 'EXIT' );     {'N' less than 'X': Returns TRUE}

For More Information:

8.54 MALLOC_C_STR Function

The MALLOC_C_STR function takes a Pascal string expression, calls the C routine malloc() to allocate memory, initializes the memory with the string expression, and then terminates the string with a null-character.


 MALLOC_C_STR(e)

The type of the expression e must be a Pascal string expression. The function result is a C_STR_T pointer to the null-terminted string. The amount of memory allocated with malloc() is equal to the length of the string expression plus one. The memory allocated with MALLOC_C_STR must be deallocated with the C free() routine. The compiler will not allow C_STR_T parameters with the NEW and DISPOSE routines.

8.55 MAX Function

The MAX function returns a value (the same type as that of the parameters) that is the maximum value of a specified list of parameters.


MAX( x1,...,xn )

The parameters can be any arithmetic type, but they must all be of the same type.

8.56 MFPR Function (OpenVMS VAX systems only)

The MFPR function returns an unsigned value that is the value of a
VAX internal processor register.


MFPR( ipr-register-expression )

The ipr-register-expression parameter is an expression compatible with the UNSIGNED type.

When you call this function, the value of the internal processor register is retrieved with the MFPR privileged VAX instruction.

Note

The HP Pascal compiler generates user-mode code. HP Pascal does not explicitly support the running of HP Pascal generated code in kernel mode. However, if the following rules are observed, then the generated code has a good chance of working as expected in elevated access modes:
  • All code must be compiled with the /NOCHECK qualifier or [CHECK(NONE)] attribute. The HP Pascal run-time signaling method relies on trying to execute the HALT instruction. In user-mode, this causes an exception that is a signal to the HP Pascal Run-Time Library. In kernel mode, this HALTs the machine.
  • Avoid all routine calls that translate into run-time library calls. These include all I/O routines, several arithmetic routines, several string routines, and so forth.

8.57 MIN Function

The MIN function returns a value (of the same type as that of the parameters) that is the minimum value of a specified list of parameters.


MIN( x1,...,xn )

The parameters can be any arithmetic type, but must all be of the same type.

8.58 MTPR Procedure (OpenVMS VAX systems only)

The MTPR procedure assigns a value into a VAX internal processor register.


MTPR( ipr-register-expression, source-expression );

The ipr-register-expression and source-expression parameters are expressions compatible with the unsigned type. HP Pascal stores the value specified by source-expression into the internal processor register specified by the ipr-register-expression.

For More Information:

  • On running in kernel mode or on using the MFPR procedure ( Section 8.56)

8.59 NE Function

The NE function returns a Boolean value that specifies if the parameters are not equal according to the ASCII values of the strings' characters.


NE( str1, str2 )

The parameters str1 and str2 must be character-string expressions. HP Pascal does not pad shorter strings with blanks. Consider the following example:


VAR
   Match : BOOLEAN;
{In the executable section:}
Match := NE( 'exit   ', 'exit' );   {Returns TRUE}
Match := NE( 'exit', 'exit' );      {Returns FALSE}

For More Information:

8.60 NEW Procedure

The NEW procedure allocates memory for the dynamic variable to which a pointer variable refers. The value of the newly allocated variable is set to the initial value of the base type if defined; otherwise, the value of the variable is undefined.


                    {t1,...,tn  }
         NEW( p [[, {d1,...,dn  } ]] )

The parameter p is a pointer variable. On OpenVMS I64 and OpenVMS Alpha systems, if the pointer type was declared with the [QUAD] attribute, the NEW procedure allocates memory from the 64-bit process address space (p2 space).

The parameters t1,...,tn are constant expressions of an ordinal type that represent nested tag-field values, where t1 is the outermost variant.

If the object of the pointer is a non schema record type with variants, then you have two ways of allocating memory. If you do not specify t parameters, HP Pascal allocates enough memory to hold any of the variants of the record. If you do specify t parameters, then HP Pascal allocates enough memory to hold only the variant or variants that you specify.

Since the t parameters cause HP Pascal to allocate memory for the variant alone and not for the whole record, you cannot assign or evaluate the record as a whole; you can assign and evaluate only the individual fields. Also, a call to NEW sets the tag fields of a variant record.

The parameters d1,...,dn are compile-time or run-time ordinal values that must be the same type as the formal discriminants of the object.

If the object of the pointer is of an undiscriminated schema type, you must specify a d parameter for each of the formal discriminants of the schema type. The d parameters discriminate the schema type in much the same way as actual discriminants in a discriminated schema. The size of the allocation is based on the value of the d parameters.

If the object is a schema record type, then you must use d parameters; you cannot use t parameters or a combination of the syntaxes. If the schema record type contains a variant (which depends on one of the formal discriminants) then the d parameter discriminates the schema, determines the variant, and allows HP Pascal to compute the necessary size of the allocation.

Note

If you specify t parameters to the NEW procedure, you must specify the same t parameters to the DISPOSE procedure that deallocates memory for the corresponding variable.

Consider the following examples:


TYPE
   Meat_Type = ( Fish, Fowl, Beef );
   Beef_Portion = ( Oz_10, Oz_16, Oz_32 );
   Var_Record = RECORD
      CASE Entree : Meat_Type OF
         Fish : ( Fish_Type : ( Salmon, Cod, Perch, Trout );
                  Lemon : BOOLEAN );
         Fowl : ( Fowl_Type : ( Chicken, Duck, Goose );
                  Sauce : ( Orange, Cherry, Raisin ));
         Beef : ( Beef_Type : ( Steak, Roast, Prime_Rib );
           CASE size : Beef_Portion OF
                     Oz_10, Oz_16 : ( Beef_Veg : ( Pea, Mixed ));
                     Oz_32        : ( Stomach_Cure :
                                    ( Bicarb, Antacid, None )));
      END;
   The_Schema( Upper_Bound : INTEGER )
               = ARRAY [1..Upper_Bound] OF INTEGER;
VAR
   To_Int        : ^INTEGER;
   To_Var_Record : ^Var_Record;
   To_Schema     : ^The_Schema;
   Bound         : INTEGER VALUE 32;

{In the executable section:}
NEW( To_Int );  {Memory for To_Int^ allocated but not initialized}

NEW( To_Var_Record, Fish ); {Memory allocated only for Fish variant}
DISPOSE( To_Var_Record, Fish ); {Specify Fish to DISPOSE}
NEW( To_Var_Record, Beef, Oz_32 ); {Allocates more memory this time}
DISPOSE(To_Var_Record, Beef, Oz_32 );

NEW( To_Schema, Bound ); {Allocation for undisc. schema object}
DISPOSE( To_Schema );

For More Information:


Previous Next Contents Index