Contents | Prev | Next | Index


Standard Functions

Pascal has a number of predeclared standard functions. Some are generic functions, they usually apply to several types of operands. Standard functions are automatically imported by every Pascal unit or program. In this compiler, standard functions are rooted in the SYSTEM unit.

Arithmetic Routines:

FUNCTION ABS(x);
Absolute value of integer or real value x, result type = argument type.
FUNCTION ArcCos( r : DOUBLE ) : DOUBLE;
Arccosine of r. ArcCos(x) = ArcTan (Sqrt (1-Sqr (x)) /x);
FUNCTION ArcSin( r : DOUBLE ) : DOUBLE;
Arcsine of r. ArcSin(x) = ArcTan(x / Sqrt(1-Sqr( x )));
FUNCTION ArcTan( r : DOUBLE ) : DOUBLE;
Arctangent of  r.
FUNCTION Cos( r : DOUBLE ) : DOUBLE;
Cosine of the angle r, in radians.
FUNCTION Exp( r : DOUBLE ) : DOUBLE;
Exponential of r, that is, e raised to the power of r, where e is the base of the natural logarithms.
FUNCTION Frac( r : DOUBLE ) : DOUBLE;
Fractional part of the argument r; that is,  Frac(r) = r - Int(r).
FUNCTION Int( r : DOUBLE ) : DOUBLE;
Integer part of the argument r, r rounded toward zero.
FUNCTION Ln( r : DOUBLE ) : DOUBLE;
Natural logarithm (Ln(e) = 1) of the expression r.
FUNCTION Pi : DOUBLE;
Value of Pi, which is defined as 3.1415926535897932385.
FUNCTION Sin( r : DOUBLE ) : DOUBLE;
Sine of the angle r, in radians.
FUNCTION Sqr( r : DOUBLE ) : DOUBLE;
Square of r, or r*r.
FUNCTION Sqrt( r : DOUBLE ) : DOUBLE;
Square root of r.
FUNCTION Tan( r : DOUBLE ) : DOUBLE;
Tangent of r. Tan(r) = Sin(x) / Cos(x);

File and Text I/O:

FUNCTION Eof( VAR F ): BOOLEAN;
Returns TRUE if position of typed or untyped file at end of file.
FUNCTION Eof : BOOLEAN;
FUNCTION Eof( VAR F : TEXT ) : BOOLEAN;
Returns TRUE if at end of text. If F is omitted, the standard input is assumed.
FUNCTION Eoln : BOOLEAN;
FUNCTION Eoln( VAR F : TEXT ) : BOOLEAN;
Returns TRUE if at end of text line. If F is omitted, the standard input is assumed.
FUNCTION FilePos( VAR f : FILE ) : LONGINT;
Returns the current file position within a file. The file must be open and it can't be used on a text file.
FUNCTION FileSize( VAR f : FILE ) : LONGINT;
The size in bytes of file F.The file must be open and it can't be used on a text file.
FUNCTION IOResult : INTEGER;
Returns the status of the last I/O operation performed. I/O-checking must be turned off via a {$I-} in order to trap I/O errors using IOResult. Otherwise a runtime exception is raised for I/O errors.

Miscellaneous routines:

FUNCTION ADDR( VAR X ) : POINTER;
Get the address of variable, procedure or function X. Same as address operator.
FUNCTION Hi( X : 16-bit-integer-type ) : 8-bit-integer-type;
FUNCTION Hi( X : 32-bit-integer-type ) : 16-bit-integer-type;
Returns the high portion of a 16 or 32 bit integer value.
FUNCTION Lo( X : 16-bit-integer-type ) : 8-bit-integer-type;
FUNCTION Lo( X : 32-bit-integer-type ) : 16-bit-integer-type;
Returns the low portion of a 16 or 32 bit integer value.
FUNCTION ParamCount : INTEGER;
Returns the number of parameters passed to the program on the command line. Separate parameters with spaces or tabs. Use double quotes to wrap multiple words as one parameter (such as long file names containing spaces).
FUNCTION ParamStr( N : INTEGER ) : STRING;
Returns the Nth command line parameter. N must be greater than 0.
FUNCTION Random : REAL;
Returns a random number within the range 0.0 <= X < 1.0.
FUNCTION SizeOf(X) : INTEGER;
Returns the size of variable or type X. This function only produces meaningful results for nonstructured basic types because of Java.
FUNCTION Swap( X : 16-bit-integer-type ) : 16-bit-integer-type;
FUNCTION Swap( X : 32-bit-integer-type ) : 32-bit-integer-type;
Swaps the lo and hi portion of value X.
FUNCTION UpCase( ch : CHAR ) : CHAR;
Returns the upper case of UNICODE character ch using method java.lang.Character.toUpperCase.

Ordinal routines:

FUNCTION ODD( X : LONGINT ) : BOOLEAN;
Returns TRUE if X is an odd number.
FUNCTION PRED( X : ordinal-type ) : ordinal-type;
Returns the predecessor of an ordinal value X.
FUNCTION SUCC( X : ordinal-type ) : ordinal-type;
Returns the successor of an ordinal value X.

String routines:

FUNCTION Concat( s1, s2 : STRING ) : STRING;
String cancatenation.
FUNCTION Copy( S : STRING; i : INTEGER; Count : INTEGER ) : STRING;
Get a substring. If index i > length of S, return empty string. Else if i+Count > length of S return substring from i to end of S.
FUNCTION Length( S : STRING ) : INTEGER;
Number of actual characters in string S.
FUNCTION Pos( SubStr : STRING; S : STRING ) : INTEGER;
Searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. If Substr is not found, Pos returns zero.
FUNCTION StringOfChar( Ch : CHAR; Count : INTEGER ) : STRING;
Returns a string containing Count characters with the character value given by Ch.

Transfer routines:

FUNCTION CHR( n : WORD ) : CHAR;
Returns the UNICODE character with the ordinal value n.
FUNCTION HIGH( x : ordinal-type ) : ordinal-type;
FUNCTION HIGH( ordinal-type ) : ordinal-type;
Returns the highest value of an ordinal type.
FUNCTION HIGH( x : array-type ) : index-type;
FUNCTION HIGH( array-type ) : index-type;
Returns the highest value of the index type of an array.
FUNCTION HIGH( string-type ) : INTEGER;
Returns the declared number of string elements.
FUNCTION HIGH( x : string-type ) : INTEGER;
Returns the actual number of string elements.
FUNCTION HIGH( x : ARRAY OF type ) : INTEGER;
Returns the actual number of array elements.
FUNCTION LOW( x : ordinal-type ) : ordinal-type;
FUNCTION LOW( ordinal-type ) : ordinal-type;
Returns the lowest value of an ordinal type.
FUNCTION LOW( x : array-type ) : index-type;
FUNCTION LOW( array-type ) : index-type;
Returns the lowest value of the index type of an array.
FUNCTION LOW( string-type ) : INTEGER;
Returns the lowest string index which is always 1.
FUNCTION LOW( x : string-type ) : INTEGER;
Returns the lowest string index which is always 1.
FUNCTION LOW( x : ARRAY OF type ) : INTEGER;
Returns the lowest array index which is always zero.
FUNCTION ORD( x : ordinal-type ) : LONGINT;
Returns the ordinal number of an ordinal expression.
FUNCTION Round( r : DOUBLE ) : LONGINT;
Rounds a real-type value to an integer-type value.
FUNCTION Trunc( r : DOUBLE ) : LONGINT;
Truncates a real-type value to an integer-type value.


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com