Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
16
Добавлен:
10.12.2013
Размер:
205.08 Кб
Скачать
Copyright (c) 1998-2000 Stuart King. All rights reserved.

Welcome to the Irie Pascal Programmer's Reference Manual

-----------------
Table Of Contents
-----------------
1 Introduction
1.1 Grammar Notation
2 Lexical Elements
2.1 Character Literals
2.2 String Literals
2.3 Whole Numbers
2.3.1 Decimal Whole Numbers
2.3.2 Hexadecimal Whole Numbers
2.3.3 Binary Whole Numbers
2.4 Reals
2.5 Special Symbols
2.6 Reserved Words
2.7 Identifiers
2.7.1 Directives
2.7.2 Built-in Identifiers
2.7.3 User Defined Identifiers
2.8 Comments
3 Labels
4 Constants
4.1 boolean
4.2 maxbyte
4.3 maxchar
4.4 maxint
4.5 maxword
4.6 Nil
4.7 Permission
4.8 Platform
4.9 FileMode
4.10 dir_bit
5 Types
5.1 Enumerated Types
5.2 Subrange Types
5.3 Pointer Types
5.4 Array Types
5.5 String Types
5.6 Record Types
5.7 Set Types
5.8 File Types
5.9 List Types
5.10 Type Identifiers
5.10.1 boolean
5.10.2 byte
5.10.3 char
5.10.4 dir
5.10.5 filename
5.10.6 integer
5.10.7 real
5.10.8 registers
5.10.9 text
5.10.10 word
5.11 Integral Types
6 Variables
6.1 Pointer Variables
6.2 Array Variables
6.3 String Variables
6.4 Record Variables
6.5 List Variables
7 Functions And Procedures
7.1 Built-in Functions
7.1.1 abs
7.1.2 arctan
7.1.3 chr
7.1.4 concat
7.1.5 copy
7.1.6 copyword
7.1.7 cos
7.1.8 cosh
7.1.9 countwords
7.1.10 dirsep
7.1.11 eof
7.1.12 eoln
7.1.13 exp
7.1.14 fexpand
7.1.15 filepos
7.1.16 filesize
7.1.17 frac
7.1.18 getenv
7.1.19 hex
7.1.20 int
7.1.21 ioresult
7.1.22 isalpha
7.1.23 isalphanum
7.1.24 isdigit
7.1.25 islower
7.1.26 isprint
7.1.27 isspace
7.1.28 isupper
7.1.29 isxdigit
7.1.30 keypressed
7.1.31 length
7.1.32 ln
7.1.33 log
7.1.34 locase
7.1.35 lowercase
7.1.36 odd
7.1.37 ord
7.1.38 paramcount
7.1.39 paramstr
7.1.40 pi
7.1.41 platform
7.1.42 pos
7.1.43 pred
7.1.44 random
7.1.45 readkey
7.1.46 reverse
7.1.47 round
7.1.48 sin
7.1.49 sinh
7.1.50 sqr
7.1.51 sqrt
7.1.52 succ
7.1.53 swap
7.1.54 system
7.1.55 tan
7.1.56 tanh
7.1.57 trim
7.1.58 trunc
7.1.59 upcase
7.1.60 uppercase
7.1.61 urldecode
7.1.62 wherex
7.1.63 wherey
7.2 Built-in Procedures
7.2.1 append
7.2.2 assert
7.2.3 assign
7.2.4 chdir
7.2.5 close
7.2.6 closedir
7.2.7 clrscr
7.2.8 dec
7.2.9 delay
7.2.10 delete
7.2.11 dispose
7.2.12 erase
7.2.13 exec
7.2.14 exit
7.2.15 fill
7.2.16 flush
7.2.17 fsplit
7.2.18 get
7.2.19 getdate
7.2.20 getfiledate
7.2.21 getfilemode
7.2.22 getfiletime
7.2.23 gettime
7.2.24 gotoxy
7.2.25 halt
7.2.26 inc
7.2.27 insert
7.2.28 intr
7.2.29 mkdir
7.2.30 new
7.2.31 open
7.2.32 opendir
7.2.33 pack
7.2.34 page
7.2.35 put
7.2.36 randomize
7.2.37 rawread
7.2.38 rawwrite
7.2.39 read
7.2.40 readdir
7.2.41 readln
7.2.42 rename
7.2.43 reset
7.2.44 rewinddir
7.2.45 rewrite
7.2.46 rmdir
7.2.47 seek
7.2.48 setfiledate
7.2.49 setfiletime
7.2.50 sleep
7.2.51 str
7.2.52 textbackground
7.2.53 textcolor
7.2.54 unpack
7.2.55 val
7.2.56 write
7.2.57 writeln
7.3 External Functions And Procedures
8 Expressions
8.1 Operators
8.1.1 Not Operator
8.1.2 * Operator
8.1.3 / Operator
8.1.4 Div Operator
8.1.5 Mod Operator
8.1.6 And Operator
8.1.7 And_Then Operator
8.1.8 + Operator
8.1.9 - Operator
8.1.10 Or Operator
8.1.11 Or_Else Operator
8.1.12 Xor Operator
8.1.13 shl Operator
8.1.14 shr Operator
8.1.15 = Operator
8.1.16 <> Operator
8.1.17 < Operator
8.1.18 <= Operator
8.1.19 > Operator
8.1.20 >= Operator
8.1.21 In Operator
8.2 Compatible types
9 Statements
9.1 Empty Statement
9.2 Assignment Statement
9.2.1 Assignment Compatibility
9.2.1.1 Assignment compatibility with array indexing
9.2.1.2 Assignment compatibility with value parameters
9.2.1.3 Assignment compatibility with "read"
9.2.1.4 Assignment compatibility with assignment statements
9.2.1.5 Assignment compatibility with "for"
9.2.1.6 Transfer procedures
9.3 Procedure Statement
9.4 Goto Statement
9.5 Compound Statement
9.6 If Statement
9.7 Case Statement
9.8 Repeat Statement
9.9 While Statement
9.10 For Statement
9.11 With Statement
10 Program parameters
Appendix A. Irie Pascal Grammar
Appendix B. Extensions to Pascal as specified by ISO/IEC 7185
B.1 Relaxed declarations
B.2 Constant ranges
B.3 Otherwise
B.4 Relaxed parameter list congruity
B.5 Non-numeric statement labels
B.6 Underscores in identifiers
B.7 Binary integral constants
B.8 Hexadecimal integral constants
B.9 Input and Output automatically declared
B.10 Double-quoted literals
B.11 and_then operator
B.12 or_else operator
B.13 Bitwise operators
B.13.1 shl operator
B.13.2 shr operator
B.13.3 and (Bitwise) operator
B.13.4 or (Bitwise) operator
B.13.5 not (Bitwise) operator
B.13.6 xor (Bitwise) operator
B.14 Extended constants
B.14.1 maxchar
B.14.2 usr_r
B.14.3 usr_w
B.14.4 usr_x
B.14.5 grp_r
B.14.6 grp_w
B.14.7 grp_x
B.14.8 oth_r
B.14.9 oth_w
B.14.10 oth_x
B.14.11 dir_bit
B.14.12 platform_dos
B.14.13 platform_os2
B.14.14 platform_win32
B.14.15 platform_linux
B.14.16 platform_fbsd
B.14.17 platform_solaris
B.14.18 platform_solaris_sparc
B.14.19 platform_error
B.14.20 appendmode
B.14.21 readmode
B.14.22 writemode
B.15 Extended types
B.15.1 dir
B.15.2 filename
B.15.3 list
B.15.4 string
B.16 Extended variables
B.16.1 exitcode

----------------
1 Introduction
----------------
This is the Irie Pascal Programmer's Reference Manual, and describes
the Irie Pascal language. This manual is not a tutorial and does not
attempt to teach programming. If you are new to programming or new to
Pascal you may need additional information. Fortunately there are many
excellent books which teach programming in Pascal. If you decide to
purchase a Pascal book, you should look for one that covers Standard
Pascal. For information on how to install and use Irie Pascal, see the
Irie Pascal User's Manual which should accompany this manual.

--------------------
1.1 Grammar Notation
--------------------
Context-free grammars are often used to define the syntax of programming
languages because they produce short and precise definitions. A
context-free grammar breaks the syntax of a complex language into a
number of simpler elements called non-terminal symbols. The syntax of
each non-terminal symbol is defined by a production. Each production
consists of a non-terminal symbol followed by some sort of assignment
operator, and then followed by a sequence of special symbols, terminal
symbols and non-terminal symbols. The special symbols are used to describe
how the other symbols can be combined. The terminals symbols are literal
text that can occur in the language being defined. The full context-free
grammar takes the form of a sequence of productions for all the non-terminal
symbols in the language.

The context-free grammar used in this manual has the following notation.
The equal sign is used as the assignment operator in productions to
separate the non-terminal symbol being defined from it's definition.
The special symbols are |, {}, [], and (). The | symbol is used to separate
alternatives (i.e. the grammar allows either the symbols on it's left-hand
side or the symbols on it's right-hand side). The {} symbols are used to
enclose symbols that can be repeated zero, one, or more times. The []
symbols are used to enclose optional symbols (i.e. the grammar allows the
enclosed symbols to either occur once or not occur at all). The () symbols
are used to group symbols that are evaluated together.
The terminal symbols are enclosed in single quotes ('') to distinguish them
For example here are the productions that define the syntax for identifiers.

identifier = letter { letter | digit }

letter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' |
'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' |
'u' | 'v' | 'w' | 'x' | 'y' | 'z' |
'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' |
'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' |
'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' |
'_'

digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

The productions mean:
An identifier is a letter followed by zero or more letters or digits.
A letter is a lower-case letter or an upper-case letter or an underscore.
A digit is one of the decimal numerals.

The complete grammar for Irie Pascal is given in Appendix A.

--------------------
2 Lexical Elements
--------------------
This chapter describes the elements that make up programs.

----------------------
2.1 Character Literals
----------------------
A character literal is a character enclosed in single quotes (') or
as an extension in double quotes ("). Two single quotes together can be
used to represent single quotes in character literals enclosed in single
quotes. Two double quotes together can be used to represent double quotes
in character literals enclosed in double quotes.
So "'" and '''' are both character literals containing single quotes.
And """" and '"' are both character literals containing double quotes.

Character literals are case-sensitive so 'X' is not equal to 'x'.
The syntax for character literals is as follows

character-literal = ''' string-element-one ''' |
'"' string-element-two '"'

string-element-one = '''' | printable-character

string-element-two = '""' | printable-character

printable-character = any character (including a space) that has a visual
representation.

NOTE: The production for printable-character doesn't follow the usual
notation because 1) it's tedious to write out every possible printable
character and 2) the definition for a printable character depends on
the character set being used.

Here are some examples of valid character literals:
'A' '+' ' ' '''' '"'
"A" "+" " " "'" """"

-------------------
2.2 String Literals
-------------------
A string literal is a sequences of zero, two or more characters enclosed in
single quotes (') or as an extension in double quotes. Literals with
one character are character literals not string literals. Two single quotes
together can be used to represent single quotes in string literals enclosed
in single quotes. Two double quotes together can be used to represent
double quotes in string literals enclosed in double quotes. So
"Don't" and 'Don''t' are both string literals containing Don't.
String literals are case-sensitive, so 'Hello' is not equal to 'HELLO'.
There is no explicit limit on the length of string literals but since
string literals can not span more than one line, then the limit on the
length of a line (400) implicitly limits the length of string literals.

The syntax for string literals is as follows

string-literal = empty-string | other-string

empty-string = '''' | '""'

other-string =
''' string-element-one string-element-one {string-element-one ''' |
'"' string-element-two string-element-two {string-element-two '"'

string-element-one = '''' | printable-character

string-element-two = '""' | printable-character

printable-character = any character (including a space) that has a visual
representation.

NOTE: The production for printable-character doesn't follow the usual
notation because 1) its tedious to write out every possible printable
character and 2) the definition for a printable character depends on
the character set being used.

Here are some examples of valid string literals:
'' ' ' 'Don''t' 'Say "Hello"' '!@#$%^&*()'
"" " " "Don't" "Say ""Hello""" "!@#$%^&*()"

-----------------
2.3 Whole Numbers
-----------------
Whole numbers are numbers with no fractional part.
Leading zeroes are not significant in whole numbers

The syntax for whole numbers is

whole-number = decimal-whole-number |
hexadecimal-whole-number |
binary-whole-number

Irie Pascal supports whole numbers with values between
-2147483647 and +4294967295

---------------------------
2.3.1 Decimal Whole Numbers
---------------------------
A decimal whole numnber uses base 10.

The syntax for decimal whole numbers is as follows:

decimal-whole-number = [sign] digit { digit }

sign = [ '+' | '-' ]

digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Here are some examples of valid decimal whole number

100 -0 +7453 000005

-------------------------------
2.3.2 Hexadecimal Whole Numbers
-------------------------------
As an extension Irie Pascal supports hexadecimal (base 16) whole numbers.

The syntax for hexadecimal whole numbers is as follows:

hexadecimal-whole-numbers = [sign] '$' hex-digit { hex-digit }

sign = [ '+' | '-' ]

digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

hexdigit = digit |
'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
'A' | 'B' | 'C' | 'D' | 'E' | 'F'

Here are some examples of valid hexadecimal whole numbers

$64 -$0 +$FF -$000ab4

--------------------------
2.3.3 Binary Whole Numbers
--------------------------
As an extension Irie Pascal supports binary (base 2) whole numbers.

The syntax for binary whole numbers is as follows:

binary-whole-numbers = [sign] '%' bit { bit }

sign = [ '+' | '-' ]

bit = '0' | '1'

Here are some examples of valid binary whole numbers

%01100110 -%0 +%11111111

---------
2.4 Reals
---------
Reals are numbers with fractional parts. Leading zeroes are not significant
in reals.

The syntax for reals is as follows

real = [sign] unsigned-real

sign = [ '+' | '-' ]

unsigned-real =
digit-sequence '.' fractional-part [ exponent scale-factor ] |
digit-sequence exponent scale-factor

digit-sequence = digit { digit }

fractional-part = digit-sequence

exponent = 'e' | 'E'

scale-factor = [ sign ] | digit-sequence

Here are some examples of real numbers:
-1.23456e2 which is equal to -123.456
-1.23456e02 which is also equal to -123.456
009863434455e-07 which is equal to 986.3434455
7e-1 which is equal to 0.7

Irie Pascal supports reals with values between
about 1e308 and about -1e308

-------------------
2.5 Special Symbols
-------------------
Special symbols have special meanings to the compiler.

The syntax for special symbols is given below:

special-symbol =
'+' | '-' | '*' | '/' |
'=' | '<>' | '<' | '<=' | '>' | '>=' |
'(' | ')' |
'[' | ']' | '(.' | '.)' |
':=' | '.' | ',' | ';' | '..' |
'^' | '@'

------------------
2.6 Reserved Words
------------------
Keywords have pre-defined and fixed meanings to the compiler.
The case of keywords is usually not significant so although the
syntax below uses all lowercase letters for keywords the compiler will
by default recognize keywords regardless of the case of the letters.
NOTE: There is a compiler option (-p) that will make identifiers
and keywords case-sensitive.

The syntax for keywords is given below:

keywords := 'and' | 'and_then' | 'array' |
'begin' |
'case' | 'const' |
'div' | 'do' | 'downto' |
'else' | 'end' |
'file' | 'for' | 'function' |
'goto' |
'if' | 'in' |
'label' | 'list'
'mod' |
'nil' | 'not' |
'of' | 'or' | 'or_else' | 'otherwise' |
'packed' | 'procedure' | 'program' |
'record' | 'repeat' |
'set' | 'shl' | 'shr' |
'then' | 'to' | 'type' |
'until' |
'var' |
'while' | 'with' |
'xor'

Attempts to declare an identifier with the same name as a keyword will
be rejected by the compiler.

---------------
2.7 Identifiers
---------------
Identifiers are sequences of letters and digits that start with a letter.
As an extension, Irie Pascal also supports identifiers that contain
and/or start with underscores (_). By default identifiers are not
case-sensitive so
x and X
are normally considered to be the same identifier. NOTE: There is a
compiler option (-p) that will make keywords and identifiers case-sensitive.
Some programmers prefer case-sensitive languages since these languages
consider identifiers that differ only in case to be different identifiers.
This is often used to allow strongly related identifiers to have the same
"spelling" (i.e. differ only in case).
For example consider the code fragment below.

type
STUDENT = record
name : string;
address : string;
grade : integer;
end;
var
student : STUDENT;

The use of the same "spelling" for the variable "student" and it's
type "STUDENT" emphasize the connection between the two.

You should use this compiler option with caution (or not at all) since
this feature of Irie Pascal is not supported by many (if any) other
Pascal compilers.

The syntax for identifiers is given below:

identifier = letter { letter | digit }

letter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' |
'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' |
'u' | 'v' | 'w' | 'x' | 'y' | 'z' |
'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' |
'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' |
'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' |
'_'

digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

-----------------
2.7.1 Directives
-----------------
Directives are special identifiers that can be used to give the compiler
extra information about a declaration. The compiler recognizes directives
only at specific points in a declaration, and this recognition is not
affected by and does not affect, any meaning the directive's identifier may
have outside of these specific points. So for example the "forward"
directive is recognized even if the identifier "forward" has been declared
to have some other meaning, and the use of the "forward" directive does
not affect any meaning that "forward" has been declared to have.

NOTE: Irie Pascal supports the "forward" and "external" directives
(see "7 Functions and Procedures" for more information).

---------------------------
2.7.2 Built-in Identifiers
---------------------------
Built-in identifiers are automatically declared by the compiler.
Unlike keywords, you can declare identifiers with the same name as
built-in identifiers, if you do then your declaration will override the
declaration made by the compiler. So for example the following declaration

type
boolean = (no, yes);

will override the declaration given by the compiler
type
boolean = (false, true);

Some built-in identifiers are extensions and are therefore only
declared when extensions are enabled.

-------------------------------
2.7.3 User Defined Identifiers
-------------------------------
User defined identifiers are created and bound to program entities using
declarations. You can then reference the entities using the identifiers.
Identifiers can be bound to the following kinds of entities:
Labels, Constants, Types, Variables, Procedures, and Functions.

------------
2.8 Comments
------------
Comments are sequences of characters enclosed in
{ or (*
and
} or *)

Comments are treated like spaces by the compiler and therefore have no
effect on your program except possible to separate identifiers
(e.g. the compiler treats i(* comment *)j like two separate
identifiers i j and not a single identifier ij ).

By default comments can not be nested (i.e. by default comments can not
contain other comments). So comments like

(* outer (* inner comment *) comment *)

will be terminated at the first close comment marker, like below

(* outer (* inner comment *)

the last part

comment *)

will not be treated as part of the comment and will cause a syntax
error.

There is a compiler option (-nc) that causes the compiler to support
nested comments. When this compiler option is enabled the compiler
recognizes the end of comments only when the number of close comment
markers matches the number of open comment markers. So the example
comment above will terminate only after the second *).

Both open comment markers (* and { are considered to be equivalent,
and both close comment markers *) and } are considered to be equivalent.
So attempting to trick the compiler into accepting nested comments with
something like

(* outer { inner comment } comment *)

will not work.

Nested comments are disabled by default since in Standard Pascal comments
do not nest.

----------
3 Labels
----------
Labels are markers which you can place in front of statements so that
the statements can be referenced by "goto" statements. Labels can
be digit sequences or as an extension identifiers. Leading zeroes
are not significant in labels which are digit sequences, so "009" and "9"
are the same label.

Labels must be declared (in a label declaration group) before they can be
used.

The syntax for label declaration groups is given below:

label-declaration-group = 'label' label { ',' label } ';'

label = digit-sequence | identifier

-------------
4 Constants
-------------
Constants can be character literals, string literals, whole numbers, reals,
or constant identifiers. Character and string literals, whole numbers,
and reals have already been described in previous sections
(See "2.1 Character Literals", "2.2 String Literals", "2.3 Whole Numbers",
and "2.4 Reals").
Constant identifiers are identifiers that have been bound to a constant
using a constant declaration.

Constant declarations must be placed in constant declaration groups.

The syntax for constant declaration groups is given below:

constant-declaration-group =
'const' constant-declaration ';' { constant-declaration ';' }

constant-declaration = identifier '=' constant

constant = whole-number | real | character-literal | string-literal |
constant-identifier

Here is an example of a constant definition group:

const
Space = ' ';
message = 'Hello';
first = 1;
last = 10;
DaysInYear = 365.25;
minint = -maxint;

-----------
4.1 boolean
-----------
Irie Pascal supports two built-in enumerated constants "false" and "true"
which are associated with the built-in type "boolean". The ordinal value
of "false" is zero and the ordinal value of "true" is one.

-----------
4.2 maxbyte
-----------
As an extension Irie Pascal supports the built-in integral constant
"maxbyte" which is equal to the largest byte value supported by
Irie Pascal (255).

-----------
4.3 maxchar
-----------
As an extension Irie Pascal supports the built-in character constant
"maxchar" which is equal to the largest character value supported by
Irie Pascal.

----------
4.4 maxint
----------
Irie Pascal supports the built-in integral constant "maxint" which is
equal to the largest supported integer value.

-----------
4.5 maxword
-----------
As an extension Irie Pascal supports the built-in word constant "maxword"
which is equal to the largest word value supported by Irie Pascal.

-------
4.6 Nil
-------
Irie Pascal supports a built-in constant "nil" associated with all pointer
types, this constant can be assigned to any pointer variable to indicate
that the variable doesn't point anywhere. Any pointer variable can also
be compared with "nil".

--------------
4.7 Permission
--------------
As an extension Irie Pascal supports nine built-in integral constants which
can be used with the built-in procedures "mkdir" and "getfilemode" to
specify or identify read, write, and execute permissions. Three constants
"usr_r", "usr_w", and "usr_x" specify or identify user read, write,
and execute permissions respectively (i.e. permissions associated with the
file or directories owner). Three constants "grp_r", "grp_w", and "grp_x"
specify or identify group read, write, and execute permissions
respectively (i.e. permissions associated with users belonging to the
file or directories owner's group). Three constants "oth_r", "oth_w",
and "oth_x" specify or identify other read, write, and execute permissions
respectively (i.e. permissions associated with users who do not belong
to the file or directory owner's group).

------------
4.8 Platform
------------
As an extension Irie Pascal supports seven integral constants
"platform_dos", "platform_os2", "platform_win32", "platform_linux",
"platform_fbsd", "platform_solaris", and "platform_solaris_sparc" which can
be compared with the value returned by the built-in function "platform" to
determine the platform your program is running on.

------------
4.9 FileMode
------------
As an extension Irie Pascal supports three integral constants "readmode",
"writemode", and "appendmode" which can be used with the built-in "open"
procedure to specify the mode the file should be opened in.
See also "7.2.31 open".

------------
4.10 dir_bit
------------
As an extension Irie Pascal supports the integral constant "dir_bit",
which can be AND'd with "mode" returned by "getfilemode" to determine
if a file is a directory.

---------
5 Types
---------
Types specify sets of valid values, and every constant, variable and
function return value is associated with a specific type. Most types must
be defined before they can be used, the exceptions to this rule are pointer
types. Pointer types are allowed to be used before they are defined to
allow self-referencing structures (such as linked lists) to be built.

Irie Pascal supports the following types:
enumerated types, subrange types, pointer types, array types,
string types, record types, set types, file types, list types,
type-identifiers

Type identifiers are identifiers that have been bound to a type
using a type declaration.

Type declarations must be placed in type declaration groups.

The syntax for type declaration groups is given below:

type-declaration-group =
'type' identifier '=' type-declaration ';' { type-declaration ';' }

type-declaration = identifier '=' type-denoter

type-denoter = type-identifier | new-type

type-identifier = identifier

new-type = new-ordinal-type | new-structured-type | new-pointer-type

new-ordinal-type = enumerated-type | subrange-type

new-structured-type = [ 'packed' ] array-type |
[ 'packed' ] record-type |
[ 'packed' ] set-type |
[ 'packed' ] file-type |
[ 'packed' ] list-type |
string-type

new-pointer-type = '^' domain-type |
'@' domain-type

domain-type = type-identifier

Here is an example of a type declaration group:

type
symbols = record
name : string;
value : integer;
end;
SymbolTable = list of symbols;
color = (red, green, blue);
cardinal = 0..maxint;
IntegerList = array[1..100] of integer;
characters = set of char;

--------------------
5.1 Enumerated Types
--------------------
Enumerated types specify a finite set of ordered values. Each of these
ordered values is associated with an identifier (a enumerated constant)
and has integer type.

The syntax for enumerated types is given below:

enumerated-type = '(' identifier-list ')'

identifier-list = identifier { ',' identifier }

Here are some examples of enumerated types

(red, blue, green)
(low, medium, high)
(married, divorced, widowed, single)

------------------
5.2 Subrange Types
------------------
Subrange types specify a contiguous subset of an ordinal type. This
ordinal type is known as the host type and the values of a subrange
type have the same type as it's host type.

The syntax for subrange types is give below:

subrange-type = constant '..' constant

Here are some examples of subrange types:

-100..+100
true..true
'a'..'z'

-----------------
5.3 Pointer Types
-----------------
Pointer types specify the special value "nil" and a set of values
identifying variables associated with them. The built-in procedure
"new" creates a pointer variable and associates it with the variables type.
The built-in procedure "dispose" destroys a pointer variable and
disassociates it from the variables type.

The syntax for pointer types is given below:

pointer-type = '^' domain-type |
'@' domain-type

domain-type = type-identifier

Here are some examples of pointer types:

^integer
^real

---------------
5.4 Array Types
---------------
Array types specify collections of values of the same type (called
the array's component type) and associates an index type with the
collections. Each member of an array's collection is called an array
element and is identified by a value of the array's index type.
An array's component type may itself be an array, and the component
type of the component type may also be an array. It is sometimes
easier to think about an array of arrays as a multi-dimensional
array (i.e. an array specifying a collection with an axis for each
array component, where each element is identified by values from
each component arrays index type).

Packed arrays of char having a lower bound of one and an upper bound
of two or greater are fixed length strings and have special properties.
Normally values of array types can be tested for equality and inequality
but can not be tested to see whether one is less than the other. Fixed
length strings can be tested not only for equality and inequality but
also can be tested to see whether one is less than the other. Fixed
length strings unlike other arrays can also be read from and written to
text files as a unit using the built-in procedures "read",
"readln", "write", and "writeln".

The syntax for array types is given below

array-type = 'array' '[' index-type-list ']' 'of' component-type

index-type-list = index-type { ',' index-type }

index-type = ordinal-type

ordinal-type = enumerated-type |
subrange-type |
ordinal-type-identifier

component-type = type-denoter

Here are some examples of array types:

array[1..10] of real
array[char] of boolean
array[-456..-450] of integer

NOTE:
As a shorthand notation a multi-dimensional array type can be created
by listing the index types of each of the component arrays.
In other words

array[1..10, char, boolean] of integer

is a shorthand notation for

array[1..10] of array[char] of array[boolean] of integer

----------------
5.5 String Types
----------------
As an extension Irie Pascal supports variable length strings using the
built-in type "string". Variable length strings specify collections of
characters whose length does not exceed a maximum value.

The syntax for string types is given below:

string-type = 'string' |
'string' '[' size ']' |
'string' '(' size ')'

size = integer

where
size is an integral constant, between 1 and 1048576, which specifies the
maximum length of the string. If size is not specified the maximum
length used is 255.

For example to create a variable length string type called "name" with
a maximum length of 80 use
name = string[80];
or
name = string(80);
To create a variable length string type called 'address' with a maximum
length of 255 use
address = string;
or
address = string[255];
or
address = string(255);

----------------
5.6 Record Types
----------------
Record types specify collections of values. A record type may be empty
(i.e. specify a collection with no values). Each member of a record
type's collection is called a field and is identified by a field
identifier, with the possible exception of the variant selector which
sometimes does not have a field identifier. Each member in a record's
collection has a particular type (which can be a record type).

Sometimes groups of fields in a record type are mutually exclusive.
You can use a variant part in a record type to specify mutually
exclusive groups of fields (these mutually exclusive groups are
called variants). Each variant part contains a variant selector,
the value of the variant selector determines which variant if any
is active.

The syntax for record types is given below:

record-type = 'record' field-list 'end'

field-list = fixed-part ';' variant-part [ ';' ] |
fixed-part [ ';' ] |
variant-part [ ';' ] |
empty

fixed-part = record-section { ';' record-section }

record-section = id-list ':' type-denoter

id-list = identifier { ',' identifier }

variant-part = 'case' variant-selector 'of' variant-body

variant-selector = [ identifier ':' ] ordinal-type-identifier

variant-body = variant-list [ [;] variant-part-completer ] |
variant-part-completer

variant-list = variant { ';' variant }

variant = case-constant-list ':' '(' field-list ')'

case-constant-list = case-specifier { ',' case-specifier }

case-specifier = case-constant [ '..' case-constant ]

case-constant = ordinal-constant

variant-part-completer = 'otherwise' '(' field-list ')'

Here are some examples of valid record types:

record end
record ; end

The record types above are empty.

record
name : string;
grade : integer;
end

The record type above has two fields which are identified by
"name" of type "string" and "grade" of type "integer".

Given the type below

type
clothes = (shoe, pants, shirt);

the following record type is valid

record
price : real;
case kind : clothes of
shoe : ( size : integer; );
pants : ( waist, length : integer );
shirt : ( neck : integer; sleeve : integer )
end

and contain seven fields

"price", "kind", "size", "waist", "length", "neck", and "sleeve".

The fields "price" and "kind" are always present and the value of the
field "kind" determine which of the variants if any is present. The
variants are ("size") and ("waist" and "length") and ("neck" and "sleeve").

-------------
5.7 Set Types
-------------
Set types specify combination of values of the same ordinal type
(called the set's base type). The same value can not appear more
than once. A set can be empty (i.e. have no values).

The syntax for set types is given below:

set-type = 'set' 'of' ordinal-type

Here are some examples of set types

set of char
set of boolean

--------------
5.8 File Types
--------------
File types specify collections of values that are persistent (i.e. they
remain stored when your program is not running) and have the same type
(called the file's component type). File component types can not be file
types or types which contain file types.

The syntax for file types is given below:

file-type = 'file' 'of' component-type

--------------
5.9 List Types
--------------
As an extension Irie Pascal supports list types. List types are ordered
collections values of a single type (called the list's component type).
Each member of a list's collection is identified by it's position in
the list.

The syntax for list types is given below:

list-type = 'list' 'of' component-type

---------------------
5.10 Type Identifiers
---------------------
A type identifier is an identifier that is bound to a type with a type
definition.

The following built-in type identifiers are supported by Irie Pascal:
boolean, char, dir, filename, integer, real, text, word

--------------
5.10.1 boolean
--------------
"boolean" is a built-in enumerated type with two values "false" and "true".
The ordinal value of "false" is zero and the ordinal value of "true" is
one. The conditional statement "if" and the looping statements "while"
and "repeat/until" use boolean expressions. The operators "and", "or",
"not", "and_then", "or_else" operate on boolean expressions.

-----------
5.10.2 byte
-----------
As an extension Irie Pascal supports the built-in type "byte" whoose
values are whole numbers between 0 and 255 (maxbyte)
(see also "2.3 Whole Numbers").

-----------
5.10.3 char
-----------
"char" is a built-in ordinal type with values of the current character
set.

----------
5.10.4 dir
----------
As an extension Irie Pascal supports the built-in type "dir" whose
values are directory handles
(See also "7.2.32 opendir", "7.2.40 readdir", "7.2.44 rewinddir",
and "7.2.6 closedir").

---------------
5.10.5 filename
---------------
As an extension Irie Pascal supports the built-in string type "filename"
which is the recommended type for variables used to store file and
directory names.

--------------
5.10.6 integer
--------------
"integer" is a built-in ordinal type whoose values are whole numbers
between -2147483647 and +2147483647 (maxint)
(see also "2.3 Whole Numbers").

-----------
5.10.7 real
-----------
"real" is a built-in type whose values are numbers with fractional parts
(see also "2.4 Reals").

----------------
5.10.8 registers
----------------
As an extension Irie Pascal supports the built-in type "registers",
which is a variant record type used to store the x86 processor registers
before and after calls to the built-in procedure "intr".

The record layout is given below:

regtype = (byteregs, wordregs)

registers = record
case regtype of
byteregs : ( al, ah, afill1, afill2 : byte;
bl, bh, bfill1, bfill2 : byte;
cl, ch, cfill1, cfill2 : byte;
dl, dh, dfill1, dfill2 : byte;
);
wordregs : eax, ebx, ecx, edx, esi, edi, cflag : word;
end;

-----------
5.10.9 text
-----------
"text" is a built-in file type whose values are sequences of lines.
A line is a sequence of characters and every lines in a "text" file
is terminated by an end-of-line character except possibly the last line.

------------
5.10.10 word
------------
As an extension Irie Pascal supports the built-in ordinal type "word"
whoose values are whole numbers between 0 and 4294967295 (maxword)

-------------------
5.11 Integral Types
-------------------
Integral types are one of the following types, or subranges of one
of the following types.
byte
integer
word

-------------
6 Variables
-------------
Variables are typed storage locations, and store values of their types.
Variables must be declared before they are used. Variable identifiers are
identifiers that have been bound to a variable using a variable
declaration. Variable declarations must occur in variable declaration
groups.

The syntax for variable declaration groups is given below:

variable-declaration-group =
'var' variable-declaration { ';' variable-declaration }

variable-declaration = identifier-list ':' type-denoter

identifier-list = identifier { ',' identifier }

---------------------
6.1 Pointer Variables
---------------------
Pointer variables store either the special value "nil" or a reference to
another variable. The built-in procedure "new" is used to create variables
referenced by pointer variables. The built-in procedure "dispose" is used
to destroy variables referenced by pointer variables.

-------------------
6.2 Array Variables
-------------------
Array elements can be accessed using the notation
ArrayName[Index]
where "ArrayName" is the name of the array variable and "Index" is an
expression whose value is one of the values specified by the array's
index type (see also "5.4 Array Types"). You can use either this notation
ArrayName[Index1][Index2]...[IndexN]
or this notation
ArrayName[Index1, Index2,...IndexN]
to access array elements in multi-dimensional array variables.

--------------------
6.3 String Variables
--------------------
The individual characters in a string variable can be accessed using
array notation. For example if "name" is a string variable then

name[2]

accesses the second character in the string stored in "name".

You can use the following built-in procedures and functions to
manipulate variables of string types:
concat, copy, length, lowercase, pos, reverse, trim, uppercase,
delete, insert, str, val

You can use the "+" operator to perform string concatenation.
For example here is a hello world program using string concatenation.

program good(output);
begin
writeln('hello' + ' ' + 'world' + '!')
end.

--------------------
6.4 Record Variables
--------------------
Record variable fields can be accessed using the following notation
RecordName.FieldName
where "RecordName" is the name of the record variable
and "FieldName" is the name of the field.

------------------
6.5 List Variables
------------------
You can use the following built-in procedures and functions with
variables of list types:
new, dispose, insert, delete, length

You can access the components of a list variable just like an array
variable. The syntax is
list-variable '[' integral-expression ']'
where
integral-expression is an expression of integral type that specifies
the position in the list of the component being accessed.
For example if "i" is an integer and "lv" is a list variable the
statement below will write each component of "lv".
for i := 1 to length(lv) do
writeln(lv[i])

----------------------------
7 Functions And Procedures
----------------------------
Pascal encourages modular programming (i.e. creating complex programs
from smaller and simpler modules). Ideally these modules should resemble
so called "black boxes" where the implementation details about how the
module performs its work is kept hidden inside the module, the user of
the module only needs to know "what" the module does and not "how".

Pascal supports two kinds of modules, "functions" and "procedures".
The difference between functions and procedures is that functions
return a value to their callers and are used in expressions, while
procedures do not return a value to their callers and are used in
procedure statements. Since functions and procedures are so similar
the generic term subroutine will be used to refer to both.

The recommended way of passing information into and out of subroutines
is by use of parameters. The other way of passing information into and
out of subroutines is via global variables, however this method should be
used cautiously since it may make a program more difficult to understand
and maintain. Subroutines may have a list of formal parameters, these
formal parameters are used by the subroutine to access information passed
into it by parameters. When the subroutine is called the caller must supply
an actual parameter for each formal parameter in the subroutine. The
actual parameter is the information being passed into or out of the
subroutine.

Irie Pascal supports four kinds of parameters (value parameters,
variable parameters, function parameters, and procedure parameters).

Value parameters are passed by value (i.e. when the subroutine is called
the actual parameter is an expression, and the value of the expression is
passed into the formal parameter). The subroutine can use the formal
parameter to access the value passed to it but any changes it makes
to the formal parameter will not affect the actual parameter.

Variable parameters are passed by reference (i.e. when the subroutine
is called the actual parameter is a variable, and the address of this
variable is passed into the formal parameter). The subroutine can
use the formal parameter to access the variable (via it's address)
and any changes it makes to the formal parameter will immediately
affect the actual parameter.

Function parameters store addresses of functions (i.e. when the
subroutine is called the actual parameter is a function, and the
address of this function is passed into the formal parameter).
The subroutine can use the address stored in the formal parameter
to call the function.

Procedure parameters store addresses of procedures (i.e. when the
subroutine is called the actual parameter is a procedure, and the
address of this procedure is passed into the formal parameter).
The subroutine can use the address stored in the formal parameter
to call the procedure.

For example here is an example of a simple program with a procedure.

program simple(output);

procedure say (message : string);
begin
writeln(message)
end;

begin
say('Hello world')
end.

The program contains a procedure called "say" which takes a single
value parameter. When the procedure is called "say('Hello world')"
the actual parameter is the expression 'Hello world' which is passed
into the formal parameter "message". So "message" now has the value
'Hello world'. The call to the built-in procedure "writeln" causes the
value of message (i.e. 'Hello world') to be written to the standard
output stream.

Irie Pascal supports recursive function and procedure calls (i.e.
Irie Pascal allows functions and procedures to call themselves
either directly or indirectly). For example a procedure A
can call itself or it can call another procedure say B which in turn
calls procedure A.

Functions and procedures must be declared before they can be called.
This creates a problem when you have functions or procedures that
call each other. For example suppose you have the program below.

program test(output);

procedure a(x : integer);
begin
writeln(x);
b(x+1)
end;

procedure b(x : integer);
begin
writeln(x);
a(x+1)
end;

begin
a(1);
end.

If you try to compile this program the compiler will complain about
the call to "procedure b" that occurs in "procedure a" because this call
occurs before "procedure b" is declared.
You can try to correct this problem by moving the declaration of
"procedure b" before the declaration of "procedure a" like so

program test(output);

procedure b(x : integer);
begin
writeln(x);
a(x+1)
end;

procedure a(x : integer);
begin
writeln(x);
b(x+1)
end;

begin
a(1);
end.

but then the compiler will complain about the call to "procedure a"
that occurs in "procedure b", because this call now occurs before
"procedure a" is declared.

The "forward" directive can be used to solve this kind of problem as
illustrated by the program below:

program test(output);

procedure b(x : integer); forward;

procedure a(x : integer);
begin
writeln(x);
b(x+1)
end;

procedure b;
begin
writeln(x);
a(x+1)
end;

begin
a(1);
end.

You will notice that there are two declarations for procedure b.

The first declaration is called a forward declaration and includes
the name of the procedure and the formal parameter list
("x:integer" in this case) and the directive "forward", but does not
include the procedure block.
The second declaration includes the name of the procedure and the
procedure block but does not include the formal parameter list.

As an extension Irie Pascal supports calling functions and procedures
inside Windows DLLs using the "external" directive.
See 7.3 External Functions And Procedures below for more information.

The syntax for function and procedure declarations is given below:

function-declaration =
function-heading ';' directive-specification |
function-identification ';' function-block |
function-heading ';' function-block

procedure-declaration =
procedure-heading ';' directive-specification |
procedure-identification ';' procedure-block |
procedure-heading ';' procedure-block

procedure-heading = 'procedure' identifier [ formal-parameter-list ]

procedure-identification = 'procedure' procedure-identifier

procedure-identifier = identifier

procedure-block = block

function-heading =
'function' identifier [ formal-parameter-list ] ':' result-type

function-identification = 'function' function-identifier

function-identifier = identifier

procedure-block = block

function-block = block

formal-parameter-list =
'(' formal-parameter-section { ';' formal-parameter-section } ')'

formal-parameter-section = value-parameter-specification |
variable-parameter-specification |
procedure-parameter-specification |
function-parameter-specification

value-parameter-specification = identifier-list ':' type-identifier

variable-parameter-specification =
'var' identifier-list ':' type-identifier

procedure-parameter-specification = procedure-heading

function-parameter-specification = function-heading

directive-specification = forward-directive | external-directive

forward-directive = 'forward'

external-directive = 'external' 'dll' '=' dllname ['name' '=' name]
[stdcall] [cdecl]

result-type = type-identifier

----------------------
7.1 Built-in Functions
----------------------
Irie Pascal supports the following built-in functions.

---------
7.1.1 abs
---------
Purpose: Returns the absolute value of its input.
Syntax:
abs-call = 'abs' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: Yes
Platforms: All
Example:
abs(-10) is equal to 10
Notes:
The type of the value returned by this function is always the
same as the type of its input.

------------
7.1.2 arctan
------------
Purpose: Returns the arctangent of its input
Syntax:
arctan-call = 'arctan' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

---------
7.1.3 chr
---------
Purpose: Returns the character whose ordinal value is equal to its input.
Syntax:
chr-call = 'chr' '(' num ')'

num = integral-expression

Standard Pascal: Yes
Platforms: All
Notes:

------------
7.1.4 concat
------------
Purpose: Returns a string formed by concatenating its input.
Syntax:
concat-call = 'concat' '(' s { ',' s } ')'

s = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
For example you could do something like
message := concat('Hello', ' ', 'world', '!');
to make message equal to 'Hello world!'
You can also concatenate strings and characters using the "+"
operator like
message := 'Hello' + ' ' + 'world' + '!';

----------
7.1.5 copy
----------
Purpose: Returns a string formed by copying from an input string starting
from a specified position.
Syntax:
copy-call = 'copy' '(' s ',' p [ ',' n ')'

s = character-expression | string-expression

p = integral-expression

n = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"s" is the source of characters
"p" specifies the position from which to start copying characters.
If "p" is greater than the number of charaters in "s" then
no characters are copied.
"n" specifies the number of characters to copy. If "n" is omitted or is
greater than the number of characters in "s" from "p" to the end,
then all characters in "s" starting from "p" to the end are copied.

For example
copy('Testing...', 5, 2) is equal to 'in'
and
copy('Testing...', 7) is equal to 'g...'
and
copy('Testing...', 1, 1000) is equal to 'Testing...'
and
copy('Testing...', 50) is equal to ''

--------------
7.1.6 copyword
--------------
Purpose: Returns a string formed by copying a word from an input string.
Syntax:
copyword-call = 'copyword' '(' s ',' i [ ',' s2 ] ')'

s = character-expression | string-expression

i = integral-expression

s2 = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
"s" is the input string from which the word is copied
"i" is the word index.
Words are numbered starting from one, so it is an error if
"i" is less than one. If "i" is greater than the number of
words in "s" then an empty string is returned.
"s2" if present is a string of special characters used to
deliminate words. If "s2" is not present then the default
special characters (i.e. SPACE, TAB, RETURN, and LINEFEED)
are used to deliminate words.

Here are some simple examples using the default special characters.

copyword('example', 1) is equal to 'example'
and
copyword(' example ', 1) is equal to 'example'
and
copyword('example', 2) is equal to ''
and
copyword(' another example ', 2) is equal to 'example'

Here are some examples using "," as the special character to
extract fields from comma-deliminated strings.

copyword('1234, name, value', 1, ',') is equal to '1234'
and
copyword('1234, name, value', 2, ',') is equal to ' name'
and
copyword('1234, name, value', 3, ',') is equal to ' value'

See also "countwords"

---------
7.1.7 cos
---------
Purpose: Returns the cosine of its input (expressed in radians).
Syntax:
cos-call = 'cos' '(' num ')'

num = integral-expression | real-expression
Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

----------
7.1.8 cosh
----------
Purpose: Returns the hyperbolic cosine of its input.
Syntax:
cosh-call = 'cosh' '(' num ')'

num = integral-expression | real-expression
Standard Pascal: No
Platforms: All
Notes:
The type of the value returned by this function is always real.

----------------
7.1.9 countwords
----------------
Purpose: Returns the number of words in an input string.
Syntax:
countwords-call = 'countwords' '(' s [ ',' s2 ] ')'

s = character-expression | string-expression

s2 = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
"s" is the input string whoose words are counted
"s2" if present is a string of special characters used to
deliminate words. If "s2" is not present then the default
special characters (i.e. SPACE, TAB, RETURN, and LINEFEED)
are used to deliminate words.

Here are some simple examples using the default special characters.

countwords('example') is equal to 1
and
countwords(' example ') is equal to 1
and
countwords(' another example ') is equal to 2

Here are some examples using "," as the special character to
count fields in comma-deliminated strings.

countwords('1234, name, value', ',') is equal to 3

See also "copyword"

-------------
7.1.10 dirsep
-------------
Purpose: Returns the directory seperator for the current platform.
Syntax
dirsep-call = 'dirsep'
Standard Pascal: No
Platforms: All
Notes:
On Windows, DOS, OS/2 the value returned is "\".
On Linux, FreeBSD, Solaris/x86 and Solaris_sparc the value returned is "/".

----------
7.1.11 eof
----------
Purpose: Returns "true" or "false" depending on whether its input
(which is a file variable) is at end-of-file.
Syntax:
eof-call = 'eof' [ '(' f ')' ]

f = file-variable

If "f" is omitted then the built-in file variable "input" shall be used as
input to this function.
Standard Pascal: Yes
Platforms: All
Notes:

-----------
7.1.12 eoln
-----------
Purpose: Returns "true" or "false" depending on whether its input
(which is a file variable) is at end-of-line.
Syntax:
eoln-call = 'eoln' [ '(' t ')' ]

t = text-file-variable

If "t" is omitted then the built-in text file variable "input" shall be
used as input to this function.
Standard Pascal: Yes
Platforms: All
Notes:

----------
7.1.13 exp
----------
Purpose: Returns the value of "e" raised to the power of its input.
Syntax:
exp-call = 'exp' '(' num ')'

num = integral-expression | real-expression
Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

--------------
7.1.14 fexpand
--------------
Purpose: Returns the full pathname of its input (which is a filename).
Syntax:
fexpand-call = 'fexpand' '(' s ')'

s = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.15 filepos
--------------
Purpose: Returns the value of the file position indicator of a file.
Syntax:
filepos-call = 'filepos' '(' f ')'

f = file-variable

Standard Pascal: No
Platforms: All
Notes:
This function returns an integral value.
The file variable "f" must be open.
For a text file variable the value of the file position indicator may
not be equal to the number of characters read/written so far.
For a binary file the value of the file position indicator is equal to
the number of characters read/written so far.

---------------
7.1.16 filesize
---------------
Purpose: Returns the size of a file.
Syntax:
filesize-call = 'filesize' '(' f ')'

f = file-variable

Standard Pascal: No
Platforms: All
Notes:
This function returns an integral value.
The file variable "f" must be open.

-----------
7.1.17 frac
-----------
Purpose: Returns the fractional part of a real expression.
Syntax:
frac-call = 'frac' '(' r ')'

r = real-expression

Standard Pascal: No
Platforms: All
Notes:
For example frac(7.234) is equal to 0.234
The type of the value returned by this function is always real.

-------------
7.1.18 getenv
-------------
Purpose: Returns the environment variable specified by its input.
Syntax:
genenv-call = 'getenv' '(' s ')'

s = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
If a string matching "s" can not be found in the environment list then an
empty string is returned.

----------
7.1.19 hex
----------
Purpose: Returns the hexadecimal representation of its input as a string.
Syntax:
hex-call = 'hex' '(' i ')'

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
For example hex(16) is equal to '10'.

----------
7.1.20 int
----------
Purpose: Returns the integral part of a real expression.
Syntax:
int-call = 'int' '(' r ')'

r = real-expression
Standard Pascal: No
Platforms: All
Notes:
For example int(7.234) is equal to 7.0
The type of the value returned by this function is always real.

---------------
7.1.21 ioresult
---------------
Purpose: Returns the error code of the last input/output operation.
Syntax:
ioresult-call = 'ioresult'
Standard Pascal: No
Platforms: All
Notes:
By default (when I/O checking is enabled) your program automatically
checks for errors after each I/O operation and terminates with an error
message if any errors are detected. If you do not want this default
behavior you can disable I/O checking (either globally using the "i"
compiler option or locally using the "i" compiler directive) and call
this function to determine if any I/O errors occurred.
(See "Appendix F" of the "Irie Pascal Users Manual" for a list of the error
codes returned by this function.
This function resets the error code to zero after it is called, so if you
call this function twice after an I/O operation then the second call
will always return 0. If you need to refer to the error code more than once
you can save the error code into a variable.
For example:
errcode := IOResult;
if errcode <> 0 then
case errcode of
1: writeln('Error erasing file');
2: writeln('Error renaming file');
3: writeln('File is undefined')
end

--------------
7.1.22 isalpha
--------------
Purpose: Returns "true" or "false" depending on whether its input
is a alphabetic character.
Syntax:
isalpha-call = 'isalpha' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

-----------------
7.1.23 isalphanum
-----------------
Purpose: Returns "true" or "false" depending on whether its input
is a alphanumeric character.
Syntax:
isalphanum-call = 'isalphanum' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.24 isdigit
--------------
Purpose: Returns "true" or "false" depending on whether its input
is a digit character.
Syntax:
isdigit-call = 'isdigit' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.25 islower
--------------
Purpose: Returns "true" or "false" depending on whether its input
is a lower case letter.
Syntax:
islower-call = 'islower' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.26 isprint
--------------
Purpose: Returns "true" or "false" depending on whether its input
is a printable character.
Syntax:
isprint-call = 'isprint' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.27 isspace
--------------
Purpose: Returns "true" or "false" depending on whether its input
is a white space character.
Syntax:
isspace-call = 'isspace' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

--------------
7.1.28 isupper
--------------
Purpose: Returns "true" or "false" depending on whether its input
is an upper case letter.
Syntax:
isupper-call = 'isupper' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

---------------
7.1.29 isxdigit
---------------
Purpose: Returns "true" or "false" depending on whether its input
is a hexadecimal digit character.
Syntax:
isxdigit-call = 'isxdigit' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

-----------------
7.1.30 keypressed
-----------------
Purpose: Returns "true" or "false" depending on whether there are
unread key presses waiting in the keyboard buffer.
Syntax:
keypressed-call = 'keypressed'

Standard Pascal: No
Platforms: Windows, DOS, OS/2
Notes:

-------------
7.1.31 length
-------------
Purpose: Returns the length of its input.
Syntax:
length-call = 'length' '(' v ')'

v = list-variable | string-variable

Standard Pascal: No
Platforms: All
Notes:

---------
7.1.32 ln
---------
Purpose: Returns the natural logarithm of its input.
Syntax:
ln-call = 'ln' '(' num ')'

num = integral-expression | real-expression
Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

----------
7.1.33 log
----------
Purpose: Returns the logarithm to the base 10 of its input.
Syntax:
log-call = 'log' '(' num ')'

num = integral-expression | real-expression
Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

-------------
7.1.34 locase
-------------
Purpose: Returns the lowercase letter corresponding to its input.
If there is no lowercase letter corresponding to its input
then its input is returned.
Syntax:
locase-call = 'locase' '(' c ')'

c = character-expression
Standard Pascal: No
Platforms: All
Notes:

----------------
7.1.35 lowercase
----------------
Purpose: Returns a string formed by converting all upper case characters
in its input to lower case characters and leaving all other
characters unchanged.
Syntax:
lowercase-call = 'lowercase' '(' s ')'

s = string-expression
Standard Pascal: No
Platforms: All
Notes:

----------
7.1.36 odd
----------
Purpose: Returns "true" or "false" depending on whether its input
is an odd number.
Syntax:
odd-call = 'odd' '(' i ')'

i = integral-expression
Standard Pascal: Yes
Platforms: All
Notes:

----------
7.1.37 ord
----------
Purpose: Returns the ordinal value of its input.
Syntax:
ord-call = 'ord' '(' o ')'

o = ordinal-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always integer
or word.

-----------------
7.1.38 paramcount
-----------------
Purpose: Returns the number of arguments passed to the program.
Syntax:
paramcount-call = 'paramcount'
Standard Pascal: No
Platforms: All
Notes:
For example the following is the sample program "args.pas".

program args(output);
begin
writeln('Number of program arguments =', paramcount)
end.

If you compile it and run it as follows
ipc args
ivm args this is a test
then the output would be
Number of program arguments = 4

---------------
7.1.39 paramstr
---------------
Purpose: Returns the ith program argument string where i is its input.
Syntax:
paramstr-cal = 'paramstr' '(' i ')'

i = integral-expression
Standard Pascal: No
Platforms: All
Notes:
If there is no ith program argument an empty string is returned.

---------
7.1.40 pi
---------
Purpose: Returns the value of the mathematical constant pi.
Syntax:
pi-call = 'pi'
Standard Pascal: No
Platforms: All
Notes:

---------------
7.1.41 platform
---------------
Purpose: Returns an integer indicating the platform the program is
running on.
Syntax:
platform-call = 'platform'
Standard Pascal: No
Platforms: All
Notes:
As an extension Irie Pascal supports seven integer constants
"platform_dos", "platform_os2", "platform_win32", "platform_linux",
"platform_fbsd", "platform_solaris", and "platform_solaris_sparc" which
can be compared with the value returned by this function.

----------
7.1.42 pos
----------
Purpose: Searches for one string in another.
Syntax:
pos-call = 'pos' '(' needle ',' haystack [ ',' start ')'

needle = character-expression | string-expression

haystack = character-expression | string-expression

start = integral-expression

Standard Pascal: No
Platforms: All
Notes:
This functions searches "haystack" starting at position "start"
for "needle" and returns 0 if "needle" is not found or returns the
position of "needle" in "haystack". If "start" is omitted then the search
begins at position 1. If "start" is greater than the length of "haystack"
then 0 is returned.
For example
pos('o', 'Hello world') is equal to 5
pos('o', 'Hello world', 1) is equal to 5
pos('o', 'Hello world', 6) is equal to 8
pos('o', 'Hello world', 256) is equal to 0

-----------
7.1.43 pred
-----------
Purpose: Returns an ordinal value that is one less than its input.
Syntax:
pred-call = 'pred' '(' o ')'

o = ordinal-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always the same
as the type of its input.

-------------
7.1.44 random
-------------
Purpose: Returns a pseudo-random number.
Syntax:
random-call = 'random' [ '(' i ')' ]

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
If "i" is not specified then "random" returns a real value between
0 and 1.
If "i" is specified then "random" returns an integral value
between 0 and "i"-1.
See also "7.2.36 randomize".

--------------
7.1.45 readkey
--------------
Purpose: Returns a character containing the next keypress in the keyboard
buffer. If there are no keypresses in the keyboard buffer then
this function waits until a key is pressed (you can use
the "keypressed" function to check for keypresses before
calling this function).
Syntax:
readkey-call = 'readkey'

Standard Pascal: No
Platforms: Windows, DOS, and OS/2
Notes:
If the key pressed is a printable character then this function simply
returns the character, however if the keypressed is not printable
(e.g. Page Up) then this function actually returns two characters on
separate calls to this function. In other words this function has to
be called twice to completly read non-printable key presses from the
keyboard buffer. The first call to this function returns "chr(0)" and
the second returns the scan code for the key.

--------------
7.1.46 reverse
--------------
Purpose: Returns a string created by reversing the characters in its input.
Syntax:
reverse-call = 'reverse' '(' s ')'

s = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
For example
reverse('Hello') is equal to 'olleH'

------------
7.1.47 round
------------
Purpose: Returns the integral value closes to its input.
Syntax:
round-call = 'round' '(' r ')'

r = real-expression

Standard Pascal: Yes
Platforms: All
Notes:
For example round(7.234) is equal to 7.
The type of the value returned by this function is always integer
or word.

----------
7.1.48 sin
----------
Purpose: Returns the sine of its input (expressed in radians).
Syntax:
sin-call = 'sin' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

-----------
7.1.49 sinh
-----------
Purpose: Returns the hyperbolic sine of its input.
Syntax:
sinh-call = 'sinh' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: No
Platforms: All
Notes:
The type of the value returned by this function is always real.

----------
7.1.50 sqr
----------
Purpose: Returns the square of its input
Syntax:
sqr-call = 'sqr' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always the same as
the type of its input.

-----------
7.1.51 sqrt
-----------
Purpose: Returns the square-root of its input
Syntax:
sqrt-call = 'sqrt' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always real.

-----------
7.1.52 succ
-----------
Purpose: Returns an ordinal value that is one more than its input.
Syntax:
succ-call = 'succ' '(' o ')'

o = ordinal-expression

Standard Pascal: Yes
Platforms: All
Notes:
The type of the value returned by this function is always the same
as the type of its input.

-----------
7.1.53 swap
-----------
Purpose: Returns an integral value calculated by reversing the byte
ordering of its input.
Syntax:
swap-call = 'swap' '(' i ')'

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
For example assuming 32 bit little endian integers then 256 is stored in
four bytes as follows:

0 0 1 0

So swap(256) results in the following integer:

0 1 0 0

which is equal to 65536

-------------
7.1.54 system
-------------
Purpose: Passes its input to the command processor, which will attempt to
execute it as a command.
Syntax:
system-call = 'system' '(' s ')'

s = string-expression

Standard Pascal: No
Platforms: All
Notes:
If there is an error then "system" returns a non-zero value indicating
the kind of error.
If there is no error then "system" returns zero.

See also "7.2.13 Exec".

For example the sample program "batch.pas" below is a very primitive
batch processor. It sends each line in the input file to the command
processor to be executed.

program batch(f, output);
var
f : text;
s : string;
err : integer;
begin
reset(f); (* open input file or standard input file *)
while not eof(f) do
begin
readln(f, s);
writeln('Executing ', s);
err := system(s); (* Pass 's' to the command processor *)
writeln('Error code is ', err)
end
end.

----------
7.1.55 tan
----------
Purpose: Returns the tangent of its input (expressed in radians).
Syntax:
tan-call = 'tan' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: No
Platforms: All
Notes:
The type of the value returned by this function is always real.

-----------
7.1.56 tanh
-----------
Purpose: Returns the hyperbolic tangent of its input.
Syntax:
tanh-call = 'tanh' '(' num ')'

num = integral-expression | real-expression

Standard Pascal: No
Platforms: All
Notes:
The type of the value returned by this function is always real.

-----------
7.1.57 trim
-----------
Purpose: Returns a string created by removing all leading and trailing
spaces from its input.
Syntax:
trim-call = 'trim' '(' s ')'

s = string-expression

Standard Pascal: No
Platforms: All
Notes:
For example
trim(' hello ') is equal to 'hello'

------------
7.1.58 trunc
------------
Purpose: Returns an integral value formed by removing the fractional
part of its input.
Syntax:
trunc-call = 'trunc' '(' r ')'

r = real-expression

Standard Pascal: Yes
Platforms: All
Notes:
For example trunc(7.234) is equal to 7.
The type of the value returned by this function is always integer or word.

-------------
7.1.59 upcase
-------------
Purpose: Returns the uppercase letter corresponding to its input.
If there is no uppercase letter corresponding to its input
then its input is returned.
Syntax:
upcase-call = 'upcase' '(' c ')'

c = character-expression

Standard Pascal: No
Platforms: All
Notes:

----------------
7.1.60 uppercase
----------------
Purpose: Returns a string formed by converting all lower case characters
in its input to upper case characters and leaving all other
characters unchanged.
Syntax:
uppercase-call = 'uppercase' '(' s ')'

s = string-expression

Standard Pascal: No
Platforms: All
Notes:

----------------
7.1.61 urldecode
----------------
Purpose: Decodes a URL encoded string and returns the decoded result.
Syntax:
urldecode-call = 'urldecode' '(' s ')'

Standard Pascal: No
Platforms: All
Notes:
"s" is the URL encoded string to decode.

The decoding is a simple two step process.
First all pluses "+" are converted to spaces " ".
Second all hexadecimal sequences "%xx" are converted to the
equivalent binary character.

This function can be useful in Common Gateway Interface (CGI)
programs.

-------------
7.1.62 wherex
-------------
Purpose: Returns the column the cursor is on.
Syntax:
wherex-call = 'wherex'

Standard Pascal: No
Platforms: Windows and DOS
Notes:
The left-most column is column number one (not zero).

-------------
7.1.63 wherey
-------------
Purpose: Returns the row the cursor is on.
Syntax:
wherex-call = 'wherex'

Standard Pascal: No
Platforms: Windows and DOS
Notes:
The top-most row is row number one (not zero).

-----------------------
7.2 Built-in Procedures
-----------------------
Irie Pascal supports the following built-in procedures.

------------
7.2.1 append
------------
Purpose: Opens a file for writing at the end of the file, and associates
a file variable with the opened file.
Syntax:
append-call = 'append' '(' f [',' s ] ')'

f = file-variable

s = filename

Standard Pascal: No
Platforms: All
Notes:
If the file does not exist it is created. If the file exists its contents
are preserved. In either case all writes occur at the end of the file.

If a filename ("s") is specified then the filename is assigned to the
file variable before the file is opened (the file must be closed).
After the file is opened all writes will occur at the end of the file
regardless of calls to the built-in seek procedure (See "7.2.45 rewrite",
"7.2.3 assign", "7.2.31 open", "7.2.43 reset", and "7.2.47 seek").

------------
7.2.2 assert
------------
Purpose: This procedure is based on the C language macro of the same name.
The assert procedure can be enabled/disabled using the -A compiler
option. When enabled this procedure evaluates its input, which must
be a boolean expression. If the expression evaluates to false
the program is terminated. If the expression evaluates to true
this procedure does nothing.
The idea behind this procedure is that you use it during debugging
to verify that the variables in your program have the values you
expect, and after your program is debugged you don't have to
search your program and remove the calls to this procedure, instead
you just disable this procedure using a compiler option.
You should use this procedure only to test conditions that MUST be
true if your program is working correctly. A common mistake in using
this procedure is to test normal error conditions that may happen
even if your program is bug-free (such as out of memory or
invalid user input)
Syntax:
assert-call = 'assert' '(' b ')'

b = boolean-expression

Standard Pascal: No
Platforms: All
Notes:

------------
7.2.3 assign
------------
Purpose: Assigns a name to a file variable.
Syntax:
assign-call = 'assign' '(' f ',' name ')'

f = file-variable

name = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
The file variable "f" must be closed.

For example to open a file named 'README.TXT' for reading use
assign(f, 'README.TXT');
reset(f);

You can't use this function to rename a file, use the "rename" procedure
if you want to do that.

-----------
7.2.4 chdir
-----------
Purpose: Changes the current directory.
Syntax:
chdir-call = 'chdir' '(' name ')'

name = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
"name" specifies the name of the directory that is to be the new
current directory.

-----------
7.2.5 close
-----------
Purpose: Flushes and then closes a file.
Syntax:
close-call = 'close' '(' f ')'

f = file-variable

Standard Pascal: No
Platforms: All
Notes:

--------------
7.2.6 closedir
--------------
Purpose: Closes a directory.
Syntax:
closedir-call = 'closedir' '(' d ')'

d = directory-variable

Standard Pascal: No
Platforms: All
Notes:
Irie Pascal allows you to open, read, rewind, and close directories
(See also "7.2.32 opendir", "7.2.40 readdir", "7.2.44 rewinddir").

------------
7.2.7 clrscr
------------
Purpose: Clears the screen and moves the cursor to the top left corner
of the screen.
Syntax:
clrscr-call = 'clrscr'
Standard Pascal: No
Platforms: Windows and DOS
Notes:

---------
7.2.8 dec
---------
Purpose: Decrements an ordinal variable by a specified amount or by one.
Syntax:
dec-call = 'dec' '(' o [',' i ] ')'

o = ordinal-variable

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
If "i" is omitted then "o" is decremented by one.
Using this function is slightly more efficient than using
o := o - i;

-----------
7.2.9 delay
-----------
Purpose: Stops the program for a specified number of milli-seconds.
Syntax:
delay-call = 'delay' '(' ms ')'

ms = integral-expression

Standard Pascal: No
Platforms: Windows, DOS, OS/2
Notes:
"ms" is the number of milli-seconds to stop the program.

-------------
7.2.10 delete
-------------
Purpose: Deletes components from a list or a string.
Syntax:

delete-call = delete-list | delete-string

delete-list = 'delete' '(' l ',' start [',' count ] ')'

delete-string = 'delete' '(' s ',' start [ ',' count ] ')'

l = list-variable

start = integral-expression

count = integral-expression

s = string-variable

Standard Pascal: No
Platforms: All
Notes:
"start" specifies the position in the list or string to start deleting from.
"count" specifies the number of components to delete. If "count" is omitted
then all components from "start" to the end are deleted.

--------------
7.2.11 dispose
--------------
Purpose: Releases memory allocated using "new".
Syntax:
dispose-call = dispose-pointer | dispose-list

dispose-pointer = 'dispose' '(' p ')'

dispose-list = 'dispose' '(' l ')'

p = pointer-variable

l = list-variable

Standard Pascal: Yes
Platforms: All
Notes:
After the call to dispose the pointer variable or list variable is
undefined.

------------
7.2.12 erase
------------
Purpose: Deletes a file.
Syntax:
erase-call = 'erase' '(' f ')'

f = file-variable

Standard Pascal: No
Platforms: All
Notes:
The file must be closed and have a name associated with it.

-----------
7.2.13 exec
-----------
Purpose: Executes a program.
Syntax:
exec-call = 'exec' '(' p ',' 'a' ')'

p = character-expression | string-expression

a = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
"p" specifies the program to execute.
"a" specifies the arguments (if any) to be passed to the program
(see also "7.1.54 system", "7.1.38 paramcount" and "7.1.39 paramstr").

The code returned by the program if any is stored in the built-in
variable "exitcode".

-----------
7.2.14 exit
-----------
Purpose: Terminates the function/procedure/program in which it is used,
and optionally returns a value.
Syntax:
exit-call = 'exit' [ '(' e ')' ]

e = expression

Standard Pascal: No
Platforms: All
Notes:
"i" if specifies is the value to be returned by the function or program

If used in a function then "exit" terminates the function.
If used in a function named "f" then "exit(e)" is equivalent to
f := e;
exit
If used in a procedure then "exit" terminates the procedure.
If used in a procedure then "exit(x)" is an error since you can
not return a value from a procedure.
If used not in a function or procedure but in the main program
then "exit" terminates the program.
If used not in a function or procedure but in the main program
then "exit(e)" is equivalent to:
ExitCode := e;
exit
(i.e. the program is terminated with "e" as the exit code).

See also "7.2.25 halt".

-----------
7.2.15 fill
-----------
Purpose: Fills a variable with a specified value.
Syntax:
fill-call = 'fill' '(' v ',' i ')'

v = variable

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"v" specifies the variable to fill.
"i" is an integral expression which evaluates to the
value used to fill the variable.

------------
7.2.16 flush
------------
Purpose: Flushes the a file's buffers (i.e. all data waiting to be written
to the file is written).
Syntax:
flush-call = 'flush' '(' f ')'

f = file-variable

Standard Pascal: No
Platforms: All
Notes:
The file associated with "f" must be open.

-------------
7.2.17 fsplit
-------------
Purpose: Splits a filename into its component parts.
Syntax:
fsplit-call = fsplit '(' s ',' [ d ] ',' [ n ] ',' [ e ] ')'

s = character-expression | string-expression

d = string-variable

n = string-variable

e = string-variable

Standard Pascal: No
Platforms: All
Notes:
"s" specifies the filename to be split.
"d" specifies a variable to store the directory part of the filename.
"n" specifies a variable to store the name part of the filename (minus
the extension.
"e" specifies a variable to store the extension part of the filename.

Although "d", "n", and "e" are optional at least one must be specified.

----------
7.2.18 get
----------
Purpose: Reads the next component in a file into the file variable's buffer.
Syntax:
get-call = 'get' '(' f ')'

f = file-variable

Standard Pascal: Yes
Platforms: All
Notes:

--------------
7.2.19 getdate
--------------
Purpose: Retrieves the current system date.
Syntax:
getdate-call = 'getdate' '(' year ',' month ',' day ',' day_of_week ')'

year = integer-variable or word-variable

month = integer-variable or word-variable

day = integer-variable or word-variable

day_of_week = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"year" stores the current year
"month" stores the current month (1 to 12).
"day" stores the current day of the month (1 to 31)
"day_of_week" stores the current day of the week
(0 to 6 counting from Sunday).

Suppose the current system date is Wednesday September 30, 1998 then after
GetDate(year, month, day, day_of_week)
year = 1998
month = 9
day = 30
day_of_week = 3

------------------
7.2.20 getfiledate
------------------
Purpose: Returns the date a file was last modified.
Syntax:
getfiledate-call = 'getfiledate' '(' name ',' year ',' month ',' day ')'

name = character-expression | string-expression

year = integer-variable or word-variable

month = integer-variable or word-variable

day = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the file to test.
"year" stores the year the file was last modified.
"month" stores the month the file was last modified (1 to 12)
"day" stores the day of the month the file was last modified (1 to 31)

------------------
7.2.21 getfilemode
------------------
Purpose: Gets a file's mode.
Syntax:
getfilemode-call = 'getfilemode' '(' name ',' mode ')'

name = character-expression | string-expression

mode = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the file to test.
"mode" stores the file mode.

After the call "mode" can be AND'd with the following built-in constants
to determine information about the file:
The constants "usr_r", "usr_w", and "usr_x" can be AND'd with "mode"
to determine the user read, write, and execute permissions for the file.
The constants "grp_r", "grp_w", and "grp_x" can be AND'd with "mode"
to determine the group read, write, and execute permissions for the file.
The constants "oth_r", "oth_w", and "oth_x" can be AND'd with "mode"
to determine the read, write, and execute permissions for persons other
than the files owner who are not part of the file owner group.
The "dir_bit" constant can be AND'd with "mode" to determine if the file
really is a directory.

------------------
7.2.22 getfiletime
------------------
Purpose: Returns the time a file was last modified.
Syntax:
getfiletime-call = 'getfiletime' '(' name ',' hour ',' min ',' sec ')'

name = character-expression | string-expression

hour = integer-variable or word-variable

min = integer-variable or word-variable

sec = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the file to test.
"hour" stores the hour the file was last modified (0 to 23)
"min" stores the minute the file was last modified (0 to 59)
"sec" stores the second the file was last modified (0 to 61)

--------------
7.2.23 gettime
--------------
Purpose: Retrieves the current system time.
Syntax:
gettime-call = 'gettime' '(' hour ',' min ',' sec ')'

hour = integer-variable or word-variable

min = integer-variable or word-variable

sec = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"hour" stores the current hour (0 to 23)
"min" stores the current minute (0 to 59)
"sec" stores the current second (0 to 61)

-------------
7.2.24 gotoxy
-------------
Purpose: Moves the cursor
Syntax:
gotoxy-call = 'gotoxy' '(' x ',' y ')'

x = integral-expression

y = integral-expression

Standard Pascal: No
Platforms: Windows and DOS
Notes:
"x" specifies the screen column (i.e. horizontal coordinate) to move the
cursor to.
"y" specifies the screen row (i.e. vertical coordinate) to move the cursor
to.
For example to move the cursor to the top left hand corner of the screen
use "gotoxy(1, 1)"

-----------
7.2.25 halt
-----------
Purpose: Terminates the program and optionally returns an integral value
to the program's caller.
Syntax:
halt-call = 'halt' [ '(' i ')' ]

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"i" if specified is the value returned by the program.

----------
7.2.26 inc
----------
Purpose: Increments an ordinal variable by a specified amount or by one.
Syntax:
inc-call = 'inc' '(' o [ ',' amount ] ')'

o = ordinal-variable

amount = integral-expression

Standard Pascal: No
Platforms: All
Notes:
If "amount" is omitted then "o" is incremented by one.
Using this function is slightly more efficient than using
o := o + amount;

-------------
7.2.27 insert
-------------
Purpose: Inserts a component into a string or a list.
Syntax:
insert-call = insert-list | insert-string

insert-list = 'insert' '(' v ',' l [ ',' p ] ')'

insert-string = 'insert' '(' s1 ',' s2 [ ',' p ] ')'

v = expression

l = list-variable

s1 = character expression | string-expression

s2 = string-variable

Standard Pascal: No
Platforms: All
Notes:
"v" is the component to insert into the list "l", and must be assignment
compatible with the list's component type.
"l" is the list variable to insert into.
"s1" s the component to insert into the string "s2".
"s2" is the string variable to insert into.
"p" if specified indicates the position to perform the insertion. If "p" is
omitted the insertion is performed at the end of the string or list.

-----------
7.2.28 intr
-----------
Purpose: Executes a x86 processor interrupt.
Syntax:
intr-cal = 'intr' '(' intno ',' regs ')'

into = integral-expression

regs = registers-variable

Standard Pascal: No
Platforms: DOS only
Notes:
For example the following simple program uses interrupt $10
to clear the screen.

program cls;
var
regs : registers;
begin
fill(regs, 0);
regs.eax := $0012;
intr($10, regs)
end.
------------
7.2.29 mkdir
------------
Purpose: Makes a directory
Syntax:
mkdir-call = 'mkdir' '(' name ')'

name = character-expression | string-expression
Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the directory to create.

----------
7.2.30 new
----------
Purpose: Initializes a list or creates a variable for a pointer.
Syntax:
new-call = new-list | new-pointer

new-list = 'new' '(' l ')'

new-pointer = 'new' '(' p ')'

l = list-variable

p = pointer-variable

Standard Pascal: Yes
Platforms: All
Notes:

-----------
7.2.31 open
-----------
Purpose: Open a file.
Syntax:
open-call = 'open' '(' fv ',' name ',' mode ')'

fv = file-variable

name = character-expression | string-expression

mode = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the file to open.
"mode" is the file mode. You can use the built-in constants "readmode",
"writemode", and "appendmode" to specify the file mode. The "readmode"
and "writemode" constants can be added or or'd together to specify that
the file be opened for both reading and writing.

For example

open(f, "test.txt", readmode+writemode);

will open the file "test.txt" for both reading and writing. It is an
error if the file "test.txt" does not exist. If you wish to create a new
file for reading and writing you must create it first with "rewrite" or
using "open" with "writemode" only, and then close the filee, before
opening it again for reading and writing.

See also "7.2.1 append", "7.2.43 reset", "7.2.45 rewrite".

--------------
7.2.32 opendir
--------------
Purpose: Opens a directory.
Syntax:
opendir-call = 'opendir' '(' d, name ')'

d = directory-variable
name = string-variable

Standard Pascal: No
Platforms: All
Notes:
"d" is the directory variable associate with the opened directory
"name" is the name of the directory to open
Irie Pascal allows you to open, read, rewind, and close directories
(See "7.2.6 closedir", "7.2.40 readdir", and "7.2.44 rewinddir").

-----------
7.2.33 pack
-----------
Purpose: Copies some or all of the contents of an unpacked array
into a packed array.
Syntax:
pack-call = 'pack' '(' u ',' x ',' p ')'

u = unpacked-array-variable

x = expression

p = packed-array-variable

where "u" is an unpacked array
and "x" is an expression that is assignment compatible
with the index type of "u" and specifies the first
element of "u" to copy.
and "p" is a packed array
Standard Pascal: Yes
Platforms: All
Notes:
The elements of "u" and "a" must have the same type.

For example suppose you have the following arrays

p : packed array[1..10] of integer;
u : array[-10..10] of integer;

then

pack(u, 1, p)

copies elements 1 to 10 of "u" into elements 1 to 10 of "p".
Or in a more complicated example

pack(u, 9, p)

copies elements 9 to 10 of "u" into elements 1 to 2 of "p"

-----------
7.2.34 page
-----------
Purpose: This procedure is supposed to affect a text file in such
a way that subsequent output to the file appears on a new
page.
Syntax:
page-call = 'page' '(' t ')'

t = text-file-variable

Standard Pascal: Yes
Platforms: All
Notes:
Currently this procedure simply writes a form-feed to the text file.

----------
7.2.35 put
----------
Purpose: Writes the contents of a file's buffer to a file and
empties the file's buffer leaving it undefined.
Syntax:
put-call = 'put' '(' f ')'

f = file-variable

Standard Pascal: Yes
Platforms: All
Notes:
If "f" is a file variable then the file's buffer can be accessed
with "f^" or "f@".

----------------
7.2.36 randomize
----------------
Purpose: Initializes the random number generator with a seed.
Syntax:
randomize-call = 'randomize' [ '(' i ')' ]

i = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"i" if specified is the seed used to initialize the random number generator.
If "i" is omitted then the random number generated is initialized with a
seed derived from the current system date and time. Specifying "i" is useful
if you want a repeatable sequence of random numbers.

--------------
7.2.37 rawread
--------------
Purpose: Reads up to a specified number of characters into a
character buffer.
Syntax:
rawread-call = 'rawread' '(' f ',' buffer ',' count ',' actual ')'

f = file-variable

buffer = array-variable

count = integral-expression

actual = integer-variable or word-variable

Standard Pascal: No
Platforms: All
Notes:
"buffer" must be a packed array of char variable and stores the characters
read by this procedure.
"count" specifies the maximum number of characters to read.
"actual" stores the actual number of characters read by this procedure.
"actual" may be less than "count" if there was an I/O error (you can check
for this by disabling I/O checking and using the IOResult function) or if
end of file was reached.

---------------
7.2.38 rawwrite
---------------
Purpose: Writes up to a specified number of characters from a character
buffer to a file.
Syntax:
rawwrite-call = 'rawwrite' '(' f ',' buffer ',' count ',' actual ')'

f = file-variable

buffer = array-variable

count = integral-expression

actual = integral-variable

Standard Pascal: No
Platforms: All
Notes:
"buffer" must be a packed array of char variable and stores the characters
to be written by this procedure.
"count" specifies the maximum number of characters to write.
"actual" stores the actual number of characters written by this procedure.
"actual" may be less than "count" if there was an I/O error (you can check
for this by disabling I/O checking and using the IOResult function).

-----------
7.2.39 read
-----------
Purpose: This procedure reads data from a file into one or more variables.
Syntax:
read-call = 'read' read-parameter-list

read-parameter-list =
'(' [ file-variable ',' ] variable-access { ',' variable-access } ')'

Standard Pascal: Yes
Platforms: All
Notes:
If the file-variable is omitted then the built-in text file variable
"input" is used.
When this procedure reads from a text file it first attempts to convert
the text data into binary data suitable for storage in variables. In
addition when reading from a text file the variables in the variable list
must be of type real, string, char, or an integral type

--------------
7.2.40 readdir
--------------
Purpose: Reads a directory (i.e. retrieves the name of a file in the
directory).
Syntax:
readdir-call = 'readdir' '(' d ',' name ')'

d = directory-variable

name = string-variable

where "d" is a directory variable (i.e. a variable of the built-in
type "dir").
Standard Pascal: No
Platforms: All
Notes:
"d" is the directory variable associated with the directory to read.
"name" stores the filename of the next file in the directory.
See also "7.2.6 closedir", "7.2.32 opendir", and "7.2.44 rewinddir".

-------------
7.2.41 readln
-------------
Purpose: This procedure reads a line of data from a text file into one or
more variables. Any data left on the line after the read is ignored.
Syntax:
readln-call = 'readln' readln-parameter-list

readln-parameter-list =
[ '(' ( file-variable | variable-access ) { ',' variable-access } ')' ]

Standard Pascal: Yes
Platforms: All
Notes:
If the file-variable is omitted then the built-in text file variable
"input" is used.
When this procedure reads from a text file it first attempts to convert
the text data into binary data suitable for storage in variables. In
addition when reading from a text file the variables in the variable list
must be of type real, string, char, or an integral type.

-------------
7.2.42 rename
-------------
Purpose: Renames the file a file.
Syntax:
rename-call = 'rename' '(' f ',' name ')'

f = file-variable

name = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
This procedure changes the name of the file associated with the
file variable "f" to "name". This is more than just changing the name
associated with the file variable, the actual name of the file is changed.

------------
7.2.43 reset
------------
Purpose: Opens a file for reading.
Syntax:
reset-call = 'reset' '(' f [ ',' name ] ')'

f = file-variable

name = character-expression | string-expression

Standard Pascal: Yes
Platforms: All
Notes:
If "name" is specified then "name" is assigned to the file variable before
the file is opened (the file must be closed). See also "7.2.1 append",
"7.2.45 rewrite", "7.2.3 assign", "7.2.31 open", and "7.2.47 seek".

----------------
7.2.44 rewinddir
----------------
Purpose: Rewinds a directory so that reads start with the first
file in the directory.
Syntax:
rewind-call = 'rewinddir' '(' d ')'

d = directory-variable

Standard Pascal: No
Platforms: All
Notes:
See also "7.2.6 closedir", "7.2.32 opendir", and "7.2.40 readdir".

--------------
7.2.45 rewrite
--------------
Purpose: Opens a file for writing.
Syntax:
rewrite-call = 'rewrite' '(' f [ ',' name ] ')'

f = file-variable

name = character-expression | string-expression

Standard Pascal: Yes
Platforms: All
Notes:
If the file exists it's contents are deleted.
If the file does not exist it is created.
If a filename ("n") is specified then the filename is assigned to the
file variable before the file is opened (the file must be closed). See
also "7.2.1 append", "7.2.3 assign", "7.2.32 open", "7.2.43 reset",
and "7.2.47 seek".

------------
7.2.46 rmdir
------------
Purpose: Removes (deletes) a directory
Syntax:
rmdir-call = 'rmdir' '(' name ')'

name = character-expression | string-expression

Standard Pascal: No
Platforms: All
Notes:
"name" is the name of the directory to delete.

-----------
7.2.47 seek
-----------
Purpose: Sets the position indicator for a file.
Syntax:
seek-call = 'seek' '(' f ',' offset ')'

f = file-variable

offset = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"offset" specifies the new position indicator for the file.
The file associated with "f" must be open with Read access or Read/Write
access, this is necessary because the built-in functions "eof" and "eoln"
need to be able to read the file if the program can seek to any location
in the file.
See also "7.1.11 eof", "7.1.12 eoln", "7.2.31 open", "7.2.43 reset".

------------------
7.2.48 setfiledate
------------------
Purpose: Sets a files date (i.e. last modification date).
Syntax:
setfiledate-call = 'setfiledate' '(' f ',' year ',' mon ',' day ')'

f = file-variable

year = integral-expression

mon = integral-expression

day = integral-expression

Standard Pascal: No
Platforms: All
Notes:
"year" specifies the year.
"mon" specifies the month (1 to 12)
"day" specifies the day (1 to 31).

------------------
7.2.49 setfiletime
------
Соседние файлы в папке Irie Pascal