HP OpenVMS Systems Documentation 
HP Pascal for OpenVMS

Previous  Contents  Index 
The NEXT function returns an integer value that indicates the number of bytes that would be allocated for one component of the specified type in an unpacked array, or if the specified variable appeared as the cell in an unpacked array.
NEXT( x ) 
The parameter x can be a type identifier or variable.
Cells in an unpacked array are affected by alignment attributes and, by default, are byte aligned. Therefore, the size returned includes the actual size of the type or variable, in addition to trailing space required to ensure proper alignment.
If a variable that is not allocated to an integral number of bytes is passed to NEXT, the number of bits are rounded down to the nearest byte and then the number of bytes are returned.
The OCT function returns a characterstring value that is the octal equivalent of the specified parameter. The return value is compatible with all other string types.
OCT( 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. 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:
Int_Var := 427; Result := OCT( Int_Var, 10, 3 ); {Returns ' 653'} 
The ODD function returns a Boolean value that indicates if the parameter is odd.
ODD( x ) 
The parameter x must be integer or unsigned. This function returns TRUE if the value of x is odd and FALSE if the value of x is even.
The OR_ATOMIC function logically ORs the value of an expression to the value of a variable, stores the newly computed value in the variable, and returns the previous value of the variable.
OR_ATOMIC( e, v ) 
The type of the expression e must be assignment compatible with that of the variable v. The variable v must be an INTEGER, UNSIGNED, INTEGER64, or UNSIGNED64 variable and must be allocated on a natural boundary (such as, longword for INTEGER and UNSIGNED and quadword for INTEGER64 and UNSIGNED64). The result of OR_ATOMIC is the same type as the variable v.
The OR_ATOMIC function does not provide memory synchronization between multiple processors. The BARRIER predeclared routine must be used for that purpose.
This function is used to access data that is shared between two or more threads of execution.
The ORD function returns an integer value that is the position of the parameter in the ordered sequence of values of the parameter's type.
ORD( x ) 
The parameter x must be of an ordinal type. Note that the ordinal value of an INTEGER object is the integer itself. If x is of type UNSIGNED, its value must not be greater than MAXINT.
The PACK procedure copies components of an unpacked array variable to a packed array variable.
PACK( a, i, z ) 
The parameter a is an unpacked array. The parameter i is a value to indicate the starting value of the index of a. The parameter z is a packed array of the same component type as a.
The number of components in parameter a must be greater than or equal to the number of components in z. This procedure assigns the components of a, starting with a[i], to the array z, starting with z[lowbound], until all the components in z are filled.
In general, when specifying i, keep in mind that the upper bound of a
(that
is, n) must be greater than or equal to i + v  u, where v is the upper
bound of z and u is the lower bound of z. That is, ORD(n) must be
greater than or equal to ORD(i) + ORD(v)  ORD(u). Consider the
following example:
VAR a : ARRAY[1..25] OF 0..15; p : PACKED ARRAY[1..20] OF 0..15; i : INTEGER; {In the executable section:} FOR i := 1 TO 20 DO READ ( a[i] ); PACK( a, 5, p ); {a[1] through a[4] are not used} PACK( a, 1, p ); {a[21] through a[25] are not used} 
The PAD function returns a characterstring value, of the specified size, that contains padded fill characters. The return value is compatible with all other string types.
PAD( str, fill, size ) 
The parameter str is a characterstring value to be padded; the parameter fill is a value of type CHAR to be used as the fill character; and the parameter size is an integer value indicating the size of the final string.
This string is composed of the original string followed by the fill character, which is repeated as many times as is necessary to extend the string to its specified size. The final size must be greater than or equal to the length of the string to be padded.
The PAS_STR function returns a Pascal string value from a C_STR_T value.
PAS_STR(e) 
The type of the expression e must be C_STR_T. It is an error if the expression is NIL.
The PAS_STRCPY function copies a Pascal string expression into memory pointed to by C_STR_T.
PAS_STRCPY(v, e) 
The type of the variable v must be C_STR_T. The type of the expression e must be a Pascal string expression. The Pascal string is copied into the memory pointed to by the variable v. The memory is then terminated with a null character. The function returns a C_STR_T value representing the destination (such as, the same value as contained by the variable v).
The behavior of PAS_STRCPY is undefined if the length of the Pascal string expression is greater than or equal to the amount of memory pointed to by the variable v. It is an error if the variable v is NIL.
The PRED function returns the value preceding the parameter according to the parameter's data type.
PRED( x ) 
The parameter x can be of any ordinal type; however, there must be a predecessor value for x in the type.
The PRESENT function returns a Boolean value that indicates whether the actual argument list of a routine contains an argument that corresponds to a formal parameter. (This function is usually used to supply a default value or to take a default action when the argument for a parameter is omitted.)
PRESENT( parametername ) 
The parametername parameter is the name of a formal parameter with the TRUNCATE attribute. The parametername must be the name of a formal parameter of the function from which PRESENT is called, or from a subroutine of that function. The function result indicates whether the argument list of the containing routine specifies an actual argument corresponding to an optional parameter.
Parameters that do not have the TRUNCATE attribute, and also do not follow a parameter with the TRUNCATE attribute in the formal parameter list, are allowed; in their case, the PRESENT function always returns TRUE.
Default parameters are considered to be present in the argument list, and the PRESENT function returns TRUE when passed the name of a parameter with a default value.
The QUAD function converts the parameter and returns its QUADRUPLE equivalent.
QUAD( x ) 
The parameter x must be an arithmetic type.
The RANDOM function returns a randomly computed real value in the range [0.0,1.0) based on a seed that is initially set to the value 7774755. The seed used by the RANDOM function can be modified with the SEED function.
RANDOM[[( expression )]] 
If present, the optional expression parameter is ignored.
The READV procedure reads characters from a characterstring expression and assigns them to parameters in the READV call. The behavior of READV is similar to that of READLN; the character string is similar to a oneline file.
READV( str, {variableidentifier[[ : radixspecifier ]]},... [[, ERROR := errorrecovery ]] ) 
str
The str parameter is the string to be read.variable_identifier
The variableidentifier is the name of the variable to be assigned a value from str.radixspecifier
The radixspecifier parameter is one of the format values BIN, OCT, or HEX. These values, when used on a variableidentifier, read the variable in binary, octal, or hexadecimal, respectively. You can read a variable of any type by using a radixspecifier except a type that contains a file component.errorrecovery
The errorrecovery parameter is the action to be taken if an error occurs during execution of the routine.
An error occurs at run time if values have not been assigned to all the parameters listed in the READV procedure call before the end of the character string is reached, as shown in this example:
TYPE Color = ( Yellow, Red, Blue ); VAR Paint, Paint2 : Color; Month : VARYING[5] OF CHAR; Real_Var : REAL; Read_String : VARYING[17] OF CHAR; {In the executable section:} Read_String := 'Red July 26.33805'; READV( Read_String, Paint, Month, Real_Var ); {Paint contains Red, Month contains 'July', and Real_Var contains 26.33805} READV( Read_String, Paint, Month, Real_Var, Paint2 ); {Error: end of string reached after assigning to Real_Var} READV( Read_String, Paint, Month ); {Legal: '26.33805' is not used} READV( Read_String, Real_Var, Paint, Month ); {Error: Red is not REAL} 
The RENAME_FILE procedure renames a file.
RENAME_FILE( oldfilename, newfilename [[, errorreturn]] ) 
The parameter oldfilename specifies the names of one or more files whose specifications are to be changed. The newfilename parameter provides the new file specification to be applied. The errorreturn parameter contains an error recovery code if specified.
The REVERT procedure cancels a condition handler activated by the ESTABLISH procedure. This procedure does not have a parameter list.
The ROUND function converts the value of the parameter by rounding the fractional part of the value, and returns its integer equivalent.
ROUND( x ) 
The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE. of x must not be too large to be represented by an integer.
The ROUND64 function converts the value of the parameter by rounding the fractional part of the value, and returns its INTEGER64 equivalent.
ROUND64( x ) 
The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE. The value of x must not be too large to be represented by an INTEGER64.
The RSHIFT predeclared function returns a value of the same type as its first parameter. The value represents the value of the first parameter after the bits have been shifted to the right.
RSHIFT(expression, expression) 
The expression 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. The RSHIFT function inserts zero bits on the left as the bits shift right.
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.
The SEED function has a single integer parameter that sets the random number generator seed for the RANDOM function. The function returns an integer that represents the previous seed value.
SEED(expression) 
The expression parameter is an integer.
The SET_INTERLOCKED function assigns the value TRUE to the parameter and returns its original Boolean value.
SET_INTERLOCKED( b ) 
The parameter b must be a variable of type BOOLEAN. The variable does not have to be aligned; therefore, it can be a field of a packed record.
The SIN function returns a real value that represents the sine of the specified parameter.
SIN( x ) 
The parameter x can be an integer or REAL type, and is expressed in radians.
The SIZE function returns an integer value that indicates the possible or actual number of bytes that are allocated for a specified data type or variable.
SIZE( x[[,t1,...,tn]] ) 
The parameter x can be a type identifier or variable. If x is a type identifier, then the functions return an integer value that indicates the number of bytes that would be allocated for a variable or record field of type x. If x is a variable, then the functions return an integer value that indicates the number of bytes that are allocated for that variable.
In the case where the parameter x is a variant record variable or variant type identifier, SIZE returns an integer value that indicates the number of bytes that are allocated (for a variant record variable) or would be allocated (for a variant type identifier) for both the fixed portion of the record and the largest variant. In addition, you can supply additional parameters t1 through tn that correspond to the case labels of the record. The function returns an integer value that indicates the number of bytes that would be allocated by the NEW procedure for a dynamic variable of the specified variant.
If a variable that is not allocated to an integral number of bytes is passed to SIZE, the number of bits will be rounded up to the nearest byte and then the number of bytes will be returned.
Table 82 presents values returned by the alignment routines if the routines accepted objects of the specified data types.
Type or Variable  Size in Bits  Size in Bytes  

BITNEXT  BITSIZE  NEXT  SIZE  
[BIT( 1 )] BOOLEAN  1 ^{1 }  1  1 ^{2 }  1 ^{3 } 
0..25 (subrange)  5 ^{1 }  5  4 ^{4 }  4 ^{4 } 
[BYTE] 0..255
(byte) 
8  8  1  1 
[BYTE, ALIGNED( 2 )] 0..225  32 ^{5 }  8  4 ^{5 }  1 
First element of:
PACKED ARRAY [1..10] OF 0..25 
5  5  0 ^{6 }  1 ^{3 } 
PACKED ARRAY [1..10] OF 0..25  56 ^{7 }  56 ^{7 }  7  7 
Previous  Next  Contents  Index 