Difference between revisions of "Standard Pascal"
m (→Functions and Procedures: typo for internal link) |
(→Functions and Procedures: standard functions) |
||
Line 68: | Line 68: | ||
* .. | * .. | ||
− | == Functions | + | == Functions == |
− | + | All of the functions defined by Standard Pascal are implemented in Free Pascal in the [[System unit]] of the standard [[RTL|Runtime Library]]. | |
+ | === Arithmetic Functions === | ||
+ | {| class="wikitable" | ||
+ | ! Function !! Description | ||
+ | |- | ||
+ | |abs(x) | ||
+ | |Calculate the absolute value of x | ||
+ | |- | ||
+ | |arctan(x) | ||
+ | |arctan returns the arctangent of x, which can be any Real type. The resulting angle is in radial units. | ||
+ | |- | ||
+ | |cos(x) | ||
+ | |Calculate cosine of angle x (radians) | ||
+ | |- | ||
+ | |exp(x) | ||
+ | |Exp returns the exponent of x, i.e. the number e to the power x | ||
+ | |- | ||
+ | |ln(x) | ||
+ | |returns the natural logarithm of the Real parameter x. x must be positive. | ||
+ | |- | ||
+ | |sin(x) | ||
+ | |Calculate the sine of angle x (radians) | ||
+ | |- | ||
+ | |sqr(x) | ||
+ | |Calculate the square of x | ||
+ | |- | ||
+ | |sqrt(x) | ||
+ | |Calculate the square root of x. x must be positive. | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | === Transfer Functions === | ||
+ | {| class="wikitable" | ||
+ | ! Function !! Description | ||
+ | |- | ||
+ | |round(x) | ||
+ | |Round floating point value to nearest integer number and return as integer. | ||
+ | |- | ||
+ | |trunc(x) | ||
+ | |Truncate floating point x value and return as integer. | ||
+ | |- | ||
+ | |} | ||
+ | === Ordinal Functions === | ||
+ | {| class="wikitable" | ||
+ | ! Function !! Description | ||
+ | |- | ||
+ | |chr(x) | ||
+ | |Convert byte value to a character value | ||
+ | |- | ||
+ | |ord(x) | ||
+ | |Return ordinal value of an ordinal type. | ||
+ | |- | ||
+ | |pred(x) | ||
+ | |Return previous element for an ordinal type. | ||
+ | |- | ||
+ | |succ(x) | ||
+ | |Return next element of ordinal type. | ||
+ | |- | ||
+ | |} | ||
+ | === Boolean Functions === | ||
+ | {| class="wikitable" | ||
+ | ! Function !! Description | ||
+ | |- | ||
+ | |eof(f) | ||
+ | |Check for end of file f | ||
+ | |- | ||
+ | |eoln(f) | ||
+ | |Check for end of line on textfile f | ||
+ | |- | ||
+ | |odd(x) | ||
+ | |Is a x odd or even ? | ||
+ | |- | ||
+ | |} | ||
== Extensions == | == Extensions == |
Revision as of 17:20, 21 July 2016
│
العربية (ar) │
Deutsch (de) │
English (en) │
español (es) │
suomi (fi) │
français (fr) │
Bahasa Indonesia (id) │
日本語 (ja) │
português (pt) │
русский (ru) │
中文(中国大陆) (zh_CN) │
In 1974, the creator of the Pascal language, Niklaus Wirth wrote a book with Kathleen Jensen, titled Pascal User Manual and Report published by Springer-Verlag. This book became a de-facto standard for the Pascal language. In 1983 the International Standards Organization (ISO) formalized the de-facto standard as ISO 7185:1983. In 1990 ISO released an updated version - ISO 7185 :1990 - that didn't introduce any new concepts, but cleared up ambiguities and corrected errors that were in the earlier version. The ISO 7185 standard is referred to as Standard Pascal. The standard defines the minimum level that a Pascal compiler must support in order to be a true compiler of the Pascal language.
Reserved Words
The following are the standard keywords (referred to as word-symbols in the ISO 7185) that all compilers must support:
- and
- array
- begin
- case
- const
- div
- do
- downto
- else
- end
- file
- for
- function
- goto
- if
- in
- label
- mod
- nil
- not
- of
- or
- packed
- procedure
- program
- record
- repeat
- set
- then
- to
- type
- until
- var
- while
- with
Symbols
The following symbols (which the standard refers to as special-symbols) are also part of the language:
- +
- ~
- *
- /
- = (equal)
- < (less than)
- > (greater than)
- [
- ]
- .
- ,
- :
- ;
- "
- (
- )
- <> (not equal)
- <=
- >=
- := (named becomes)
- ..
Functions
All of the functions defined by Standard Pascal are implemented in Free Pascal in the System unit of the standard Runtime Library.
Arithmetic Functions
Function | Description |
---|---|
abs(x) | Calculate the absolute value of x |
arctan(x) | arctan returns the arctangent of x, which can be any Real type. The resulting angle is in radial units. |
cos(x) | Calculate cosine of angle x (radians) |
exp(x) | Exp returns the exponent of x, i.e. the number e to the power x |
ln(x) | returns the natural logarithm of the Real parameter x. x must be positive. |
sin(x) | Calculate the sine of angle x (radians) |
sqr(x) | Calculate the square of x |
sqrt(x) | Calculate the square root of x. x must be positive. |
Transfer Functions
Function | Description |
---|---|
round(x) | Round floating point value to nearest integer number and return as integer. |
trunc(x) | Truncate floating point x value and return as integer. |
Ordinal Functions
Function | Description |
---|---|
chr(x) | Convert byte value to a character value |
ord(x) | Return ordinal value of an ordinal type. |
pred(x) | Return previous element for an ordinal type. |
succ(x) | Return next element of ordinal type. |
Boolean Functions
Function | Description |
---|---|
eof(f) | Check for end of file f |
eoln(f) | Check for end of line on textfile f |
odd(x) | Is a x odd or even ? |
Extensions
There are additional keywords which are not technically part of the Standard Pascal language but are used by FPC either for additional functionality such as for implementing objects, compatibility with the error recovery concepts exposed by C++, or to provide compatibility with Borland Pascal and earlier Pascal compilers. These keywords include:
- implementation · finally · try · unit.
Types
There are the standard types:
integer · smallint · longint · real · boolean · string · char · byte
Modes supported by Free Pascal
Free Pascal supports ISO 7185 Standard Pascal with the compiler mode option -Miso and ISO/IEC 10206 Extended Pascal with -Mextendedpascal. Support of ISO 7185 started with version 3.0.0.
External links
- Standard Pascal, reference information about the ANSI ISO 7185 standard.
- ISO 7185:1990, official normative version of the Pascal standard.
- ISO/IEC 10206:1991: Extended Pascal standard