[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.84 SNGL Function

The SNGL function converts the parameter and returns its real equivalent.


SNGL( x )

The parameter x must be an arithmetic type. The value of x must not be too large to be represented by a single-precision number.

8.85 SQR Function

The SQR function returns a value (of the same type of the parameter) that represents the square of the specified parameter.


SQR( x )

The parameter x can be any arithmetic type.

8.86 SQRT Function

The SQRT function returns a real value that represents the square root of the specified parameter.


SQRT( x )

The parameter x can be an INTEGER, UNSIGNED, or REAL type. If the value of x is less than zero, an error occurs.

8.87 STATUSV Function

The STATUSV function returns an integer value that specifies the status of the last READV or WRITEV procedure completed. STATUSV does not have any parameters.

This example shows the use of the STATUSV function:



VAR
   Vary_Src   : VARYING [20] OF CHAR;
   Int_Result : INTEGER;
{In the executable section:}
Vary_Src := '255';
READV( Vary_Src, Int_Result, ERROR := CONTINUE );
IF STATUSV <> 0 THEN  {0 means READV executed successfully}
   WRITELN( 'Error in READV' );

If, however, you have an asynchronous system trap (AST) routine condition handler in your program that uses READV and WRITEV, the call of STATUSV in your main program may not return the results you expected if an AST occurred between the READV/WRITEV procedure and the STATUSV procedure.

For More Information:

8.88 SUBSTR Function

The SUBSTR function returns a substring (from a string specified as a parameter) that is of the specified starting point and length. The return value is compatible with all other string types.


SUBSTR( str, start, length )

The parameter str is a character-string value; the parameter start is an integer value indicating the starting position of the substring. The parameter length is an integer value that indicates the length of the substring.

The following rules apply to the use of the SUBSTR function:

  • The value of the starting position must be greater than 0.
  • The value of the length must be greater than or equal to 0.
  • There must be enough characters following the starting position to construct a substring of the specified length.

Consider the following example:


Original_String := 'This is the original string';
Start_Position := 13;
Substring_Length := 15;
New_String := SUBSTR( Original_String, Start_Position,
                      Substring_Length );
{New_String contains 'original string'}

For More Information:

8.89 SUCC Function

The SUCC function returns the value that succeeds the parameter according to the parameter's data type.


SUCC( x )

The parameter x can be of any ordinal type; however, there must be a successor value for x in the type.

8.90 SYSCLOCK Function

The SYSCLOCK function returns an integer value for the number of milliseconds of system time used by the current process. The result is the same as that returned by the CLOCK function.


SYSCLOCK

For More Information:

8.91 TIME Procedure

See Section 8.24.

8.92 TRUNC Function

The TRUNC function converts the value of the parameter by truncating the fractional part of the value and returns its integer equivalent.


TRUNC( x )

The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE. value of x must not be too large to be represented by an integer.

8.93 TRUNC64 Function

The TRUNC64 function converts the value of the parameter by truncating the fractional part of the value and returns its INTEGER64 equivalent.


TRUNC64( 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.

8.94 UAND Function

The UAND function returns an unsigned value that represents a binary logical AND operation on each corresponding pair of bits of the specified parameters.


UAND( u1, u2 )

The parameters u1 and u2 must be of type UNSIGNED. Consider the following example:



Result := UAND( 16#FF9, 16#703 ); {Returns 1793, which is 16#701}

For More Information:

8.95 UDEC Function

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


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

The parameter x is the expression to be converted. The UDEC function can take a parameter of any type except VARYING of CHAR, conformant parameters, or schema types. This function requires the size of the parameter x to be less than or equal to the size of INTEGER64 (if supported) on your system. If your system does not support INTEGER64, then the UDEC function requires that the parameter x be less than or equal to the size of INTEGER32.

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 minimum number of significant digits is used. If the size of the parameter x is greater than 32, the defaults are 21 characters for the length and 20 characters for the minimum number of digits. Otherwise, the defaults are 11 characters for the length and 10 characters for the minimum number of digits.

Consider the following example:



VAR
   Account : INTEGER;
{In the executable section:}
Account := 3;
WRITELN( UDEC( Account ) );

For More Information:

8.96 UINT Function

The UINT function converts the value of the parameter and returns its unsigned equivalent.


UINT(x)

The parameter x must be of an ordinal type.

No error results if x is an integer and has a negative value. The value returned is x MOD 2**32.

For More Information:

  • On range and support for the UNSIGNED data type (Chapter 2)

8.97 UINT64 Function

The UINT64 function converts the value of the parameter and returns its UNSIGNED64 equivalent.


UINT64(x)

The parameter x must be of an ordinal type.

No error results if x is an integer and has a negative value. The value returned is x MOD 2**64.

For More Information:

8.98 UNDEFINED Function

The UNDEFINED function returns a Boolean value that specifies whether the parameter contains an undefined (invalid) operand.


UNDEFINED( x )

The parameter x must be a variable of type REAL, SINGLE, DOUBLE, or QUADRUPLE.

On OpenVMS I64 and OpenVMS Alpha systems, the UNDEFINED routine returns FALSE if the floating-point value is finite and returns TRUE if the value is not finite.

A finite number is a floating-point value with a definite, in-range value. Specifically, all numbers in the inclusive ranges -MAX through -MIN, zero, and +MIN through +MAX, where MAX is the largest non-infinite representable floating-point number for the variable's type and MIN is the smallest non-zero representable normalized floating-point number for the variable's type. These correspond to the MINREAL, MAXREAL, MINDOUBLE, MAXDOUBLE, MINQUADRUPLE, and MAXQUADRULE predeclared constants.

For F_Float, D_Float, and G_Float, finites do not include reserved operands and dirty zeros (this differs from the VAX interpretation of dirty zeros as finite). For S_Float, T_Float, and X_Float, finites do not include infinites, NaNs, or denormals, but do include minus zero.

On OpenVMS VAX systems, the UNDEFINED routine returns TRUE if the floating-point value has an exponent of 0 together with a sign bit of 1; otherwise, it returns FALSE.

8.99 UNOT Function

The UNOT function returns an unsigned value that represents a binary logical NOT operation on each bit of the specified parameter.


UNOT( u )

The u parameter must be an unsigned expression. Consider the following example:



Result := UNOT( 16#FF9 );  {Returns 16#FFFFF006}

For More Information:

8.100 UNPACK Procedure

The UNPACK procedure copies components of a packed array to an unpacked array variable.


UNPACK( z, a, i )

The parameter z is a packed array. The parameter a is an unpacked array variable. The parameter i is the starting value of the index of a.

The number of components in parameter a must be greater than or equal to the number of components in z. The UNPACK procedure assigns the components of z, starting with z[low-bound], to the array a, starting with a[i], until all the components in z are used.

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).

Normally, you cannot pass the individual components of a packed array to formal VAR parameters; you must unpack the array first. Consider the following example:


VAR
   p : PACKED ARRAY[1..10] OF CHAR;
   a : ARRAY[1..10] OF CHAR;
   i : INTEGER;
PROCEDURE Process_Components( VAR Ch : CHAR ); {Body...}

{In the executable section:}
READ( p );
UNPACK( p, a, 1);
FOR i := 1 TO 10 DO
   Process_Components( a[i] ); {Pass each component to procedure}

For More Information:

8.101 UOR Function

The UOR function returns an unsigned value of a binary logical OR operation on the corresponding pair of bits of two specified parameters.


UOR( u1, u2 )

The u1 and u2 parameters must be unsigned. Consider the following example:



Result := UOR( 16#FF9, 16#703 );  {Returns 16#FFB}

For More Information:

8.102 UPPER Function

The UPPER function returns the upper bound for ordinal types, SET base types, and array indexes.


UPPER( 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, UPPER returns the upper bound of the nth dimension of x. If x is an ordinal type, UPPER returns the upper bound or largest value. If x is a SET, UPPER returns the upper bound of the SET base type. Consider the following example:



TYPE
   A_Schema( a, b : INTEGER) = a..a+b;
VAR
   x : A_Schema( 5, 10 );
{In the executable section:}
WRITELN( UPPER( BOOLEAN ) );     {Writes TRUE}
WRITELN( LOWER( x ) );           {Writes 5}
WRITELN( UPPER( x ) );           {Writes 15}

8.103 UROUND Function

The UROUND function converts the value of the parameter by rounding the fractional part of the value and returns its unsigned equivalent.


UROUND( x )

The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE.

No error results if the value of x is negative or greater than 4,294,967,295. In that case, the unsigned result is the rounded parameter value MOD 4,294,967,296.

For More Information:

  • On range and support of the UNSIGNED data type (Chapter 2)

8.104 UROUND64 Function

The UROUND64 function converts the value of the parameter by rounding the fractional part of the value and returns its UNSIGNED64 equivalent.


UROUND64( x )

The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE.

No error results if the value of x is negative or greater than MAXUNSIGNED64. In that case, the UNSIGNED64 result is the rounded parameter value MOD MAXUNSIGNED64.

For More Information:

  • On range and support of the UNSIGNED64 data type (Chapter 2)

8.105 UTRUNC Function

The UTRUNC function converts the value of the parameter by truncating the fractional part of the value and returns its unsigned equivalent.


UTRUNC( x )

The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE.

No error results if the value of x is negative or greater than 4,294,967,295. In that case, the unsigned result is the truncated parameter value MOD 4,294,967,296.

For More Information:

  • On range and support of the UNSIGNED data type (Chapter 2)

8.106 UTRUNC64 Function

The UTRUNC64 function converts the value of the parameter by truncating the fractional part of the value and returns its UNSIGNED64 equivalent.


UTRUNC64( x )

The parameter x must be of type REAL, SINGLE, DOUBLE, or QUADRUPLE.

No error results if the value of x is negative or greater than MAXUNSIGNED64. In that case, the unsigned result is the truncated parameter value MOD MAXUNSIGNED64.

For More Information:

  • On range and support of the UNSIGNED64 data type (Chapter 2)

8.107 UXOR Function

The UXOR function returns an unsigned value of a binary logical exclusive-OR operation on the corresponding pair of bits of two specified parameters.


UXOR( u1, u2 )

The u1 and u2 parameters must be unsigned.



Result := UXOR( 16#FF9, 16#703 ); {Returns 16#8FA}

For More Information:

8.108 WALLCLOCK Function

The WALLCLOCK function returns an integer value representing the number of seconds since the boot time for the system.


WALLCLOCK

For More Information:

8.109 WRITEV Procedure

The WRITEV procedure writes characters to a character-string variable of type VARYING OF CHAR or discriminated STRING, by converting the values of the parameters in the procedure call to textual representations. The behavior of WRITEV is similar to that of the WRITELN function; the character-string parameter is similar to a one-line file.


WRITEV( str, parameter-list [[, ERROR := error-recovery]] )

The str parameter is the string to be written to.

The parameter-list parameter is the variables to be assigned to str.

The error-recovery parameter is the action to be taken if an error occurs during execution of the routine.

The str parameter cannot appear within the parameter-list; if you attempt to do this, unexpected results may occur. An error occurs if WRITEV reaches the maximum length of the character string before the values of all the parameters in the procedure call have been written into the string. The error-recovery parameter indicates the action to be taken if an error occurs while the WRITEV procedure is executing. Consider the following example:



TYPE
   Flower = ( Daisy, Lily, Orchid, Tulip );
VAR
   Real_Var     : REAL VALUE 232.705;
   Write_String : VARYING[21] OF CHAR;
   Bouquet       : Flower VALUE Orchid;
{In the executable section:}
WRITEV( Write_String, Daisy, Real_Var:7:3, PRED( Bouquet ) );
{Write_String contains ' DAISY232.705   LILY'}

WRITEV( Write_String, Daisy, Real_Var:7:3, PRED( Bouquet ),
        Bouquet );
{Error: there is no more room in the string parameter}

For More Information:

  • On VARYING OF CHAR strings ( Section 2.6.2)
  • On formatting output ( Section 9.6)
  • On error recovery codes (HP Pascal for OpenVMS User Manual)


Previous Next Contents Index