Contents |
Prev |
Next |
Index
Standard Procedures
Pascal has a number of predeclared standard
procedures. Some are
generic procedures,
they usually apply to several types of
operands. Standard procedures are automatically
imported by every Pascal unit or
program. In this compiler, standard
procedures are rooted in the SYSTEM unit.
String routines:
-
PROCEDURE Delete( VAR
S : STRING; i : INTEGER; Count : INTEGER );
-
Removes a substring of Count characters from string S starting at S[i].
If i is larger than the length of S, no characters are deleted. If Count
specifies more characters than remain starting at the S[i], Delete removes
the rest of the string.
-
PROCEDURE Insert( Source
: STRING; VAR Dest : STRING; i : INTEGER );
-
Merges Source into Dest at the position Dest[index].
-
PROCEDURE
SetLength( VAR S : STRING;
Len : INTEGER );
-
Sets the actual string length.
-
PROCEDURE
SetString
( VAR s : STRING;
buffer : ARRAY OF CHAR;
len : INTEGER
);
-
Sets the contents and length of the given string variable to the block
of characters given by the buffer and len parameters.
-
PROCEDURE Str(
numeric-expr; VAR S : string-type );
-
The Str procedure converts a real or integer expression to a string
representation. The effect is like a call to Write except the resulting string
is stored in S instead of being written to a text file. numeric-expr
is to be specified in one of the following forms:
expr
expr : minimum-width
expr : minimum-width : decimals
Dynamic alloction routines:
-
PROCEDURE NEW( VAR p : POINTER
);
PROCEDURE NEW( VAR c : class-type; constructor-call );
PROCEDURE NEW( VAR c : class-type;
constructor-parameters );
-
Create new dynamic variable or new instance of a class.
-
PROCEDURE DISPOSE( VAR
p : POINTER );
PROCEDURE DISPOSE( VAR c : class-type );
-
Free allocated memory of class instance or dynamic variable and set
pointer or class to NIL.
Flow-control routines:
-
PROCEDURE
BREAK;
-
Terminates a for,
while, or
repeat statement.
-
PROCEDURE
CONTINUE;
-
Continues a for,
while, or
repeat statement.
-
PROCEDURE EXIT;
-
Exits immediately from the current block.
-
PROCEDURE HALT( code : BYTE
);
-
Stops program execution and returns to the operating system.
-
PROCEDURE RunError(
retcode : BYTE );
-
Stops program execution because of runtime error.
File and Text I/O:
-
PROCEDURE Append( VAR
f : TEXT );
-
Opens or reopens an existing file with the name assigned to F, so that
new text can be added. If the last text file character is Ctrl-Z it will
be overwritten.
-
PROCEDURE Assign( VAR
f; id : STRING );
-
Associate the name of an external file with file variable f. Varable
f is any typed or untyped or text file. If id is an empty name string, f
will be treated as a standard text input or output depending succeeding Reset(f)
or Rewrite(f).
-
PROCEDURE
AssignFile( VAR f; id :
STRING );
-
Same as Assign.
-
PROCEDURE BlockRead
( VAR F : FILE; VAR Buf; Count : LONGWORD;
VAR Result : LONGWORD
);
-
Low-level untyped file read. Only works for
structured types. Count is the number
of array elements or else it must be one. Result is set as follows: Result
= Count if completely read, Result < Count if end of file reached
pre-maturely.
-
PROCEDURE
BlockWrite
( VAR F : FILE; VAR Buf; Count : LONGWORD;
VAR Result : LONGWORD
);
-
Low-level untyped file write. Only works for
structured types. Count is the number
of array elements or else it must be one. Result is set as follows: Result
= Count if completely written, Result < Count if disk full or if
write error occured.
-
PROCEDURE ChDir( S : STRING
);
-
changes the current directory to the path specified by S.
-
PROCEDURE Close( VAR F
);
-
Close external file which was opened using Reset, Rewrite,
or Append. F is a typed or untyped or text file.
-
PROCEDURE
CloseFile( VAR F );
-
Same as Close;
-
PROCEDURE Erase( VAR f
);
-
Delete external file associated with f. f must be closed.
-
PROCEDURE Flush( VAR f
: TEXT );
-
Clears the buffer of a text file open for output by writing all buffered
characters.
-
PROCEDURE GetDir( Drive
: BYTE; VAR S : STRING );
-
Get current working directory. Only works for current Drive = 0.
-
PROCEDURE MkDir( S : STRING
);
-
Creates a new subdirectory with the path specified by string S. The
last item in the path cannot be an existing file name.
-
PROCEDURE Read(
v1 : type; ... vn : type );
PROCEDURE Read( VAR f : TEXT; v1 : type; ... vn
: type );
-
Reads text input variables which must be of
basic types or
string types. If f is omitted, standard
input is assumed.
-
PROCEDURE Read( VAR f; v1 : component; ...
vn : component );
-
Reads typed file components into variables.
-
PROCEDURE ReadLn(
v1 : type; ... vn : type );
PROCEDURE ReadLn( VAR f : TEXT; v1 : type; ...
vn : type );
-
Reads text input variables which must be of
basic types or
string types. Then skips to the
beginning of the next line. If f is omitted, standard input is assumed.
-
PROCEDURE Rename( VAR
F; NewName : STRING );
-
Changes the name of an external file.
-
PROCEDURE Reset( VAR F
);
-
Opens an existing typed or untyped or text file for reading. If it is
text file, access to set to read-only.
-
PROCEDURE Rewrite( VAR
F );
-
Creates and opens a new typed or untyped or text file. If it is a text
file, it is set to write-only.
-
PROCEDURE RmDir( S : STRING
);
-
Removes the subdirectory with the path specified by S. If the path does
not exist, is non-empty, or is the currently logged directory, an I/O error
occurs.
-
PROCEDURE Seek( VAR F :
FILE; N : LONGINT );
-
Moves the current position of a file to a specified position. You can
use Seek only on open typed or untyped files. To expand a file, use Seek(F,
FileSize(F)).
-
PROCEDURE Truncate(
VAR F : FILE );
-
Deletes all records in the file after the current file position F. The
current file position also becomes end-of-file (Eof(F) is True). F is a file
variable of any type. Truncate does not work on text files. F must be
open.
-
PROCEDURE Write(
expr1, ... exprn );
PROCEDURE Write( VAR f : TEXT; expr1, ...
exprn );
-
Writes formatted values to a text file. If f is omitted, standard output
is assumed. Each expri must be of a
basic type or a
string type and it is to be specified
in one of the following forms:
expr
expr : minimum-width
expr : minimum-width : decimal-places
where minimum-width and decimal-places are integer values
for output format sizes.
-
PROCEDURE Write( VAR f; v1 : component; ...
vn : component );
-
Write typed file components.
-
PROCEDURE WriteLn(
expr1, ... exprn );
PROCEDURE WriteLn( VAR f : TEXT; expr1, ...
exprn );
-
Write values to a text file, exactly as it is done in Write procedure,
then write an end-of-line marker as defined in the Java properties
line.separator.
Miscellaneous routines
-
PROCEDURE Exclude( VAR
S: set-type; I: base-type );
-
Removes element I from set S. Same as S := S - (i);
-
PROCEDURE FillChar(
VAR Dest; Size : INTEGER; Value : INTEGER );
-
Fills Count number of contiguous bytes or characters with a specified
value. Only works when Dest type is an array of CHAR or an array of BYTE.
-
PROCEDURE Include( VAR
S : set-type; I : base-type );
-
Incudes element I to set S. Same as S := S + (i);
-
PROCEDURE Move( VAR Source;
VAR Dest; Size : INTEGER );
-
Copies Count bytes or characters from a Source to Dest. Only works for
array of CHAR or array of BYTE.
-
PROCEDURE
Randomize;
-
Initialize random number generator for function SYSTEM.Random.
Ordinal routines:
-
PROCEDURE Dec( VAR X );
PROCEDURE Dec( VAR X; N : LONGINT );
-
Subtracts one or N from an ordinal
variable.
-
PROCEDURE Inc( VAR X );
PROCEDURE Inc( VAR X; N : LONGINT );
-
Adds one or N to an ordinal
variable.
Transfer Routines:
-
PROCEDURE VAL
( S : string-type; v : numeric-type;
VAR Code : INTEGER
);
-
Converts the string value S to its numeric representation, as if it
were read from a text file with Read. If the string is invalid, the index
of the offending character is stored in Code; otherwise, Code is set to
zero.
-
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