Index
Symbols
# (pound) character, 7 @ operator, 49
with a variable, 49 with procedures and
functions, 50
@@ operator, 53
^ (pointer) symbol, 21, 22, 33
80286 code generation
compiler switch, 231 80x87
floating-point model, 16 software emulation,
selecting, 16 80x87 code option, 235
A
$A compiler directive, 184, 226
Abs function, 181 absolute
clause syntax, 30 expressions, built-in
assembler, 199
variables, 30
abstract directive, 92
abstract methods, 92 access specifiers
property definitions, 103
accessing properties, 102
actual parameters, 56 address
factor, 42
address-of (@) operator, 21, 34, 49, 52
Align Data command, 226 aligning data, 226 allocating
Windows memory, 162 ancestors
defined, 87
and operator, 45 apostrophes in character
strings, 7
Append procedure, 139, 140 arguments
command-line compiler, 215
arithmetic
operations precison rules, 13
operators, 44 array
types, 18
variables, 32
array properties, 104
default, 105
arrays, 18, 32
accessing elements, 18 indexing
multidimensional, 32 number of elements, 18 of arrays, 18
types, 166
valid index types, 18 zero-based character, 19,
37, 153, 155
array-type constant syntax, 37
asm statement, 187
.ASM files, 152 assembler
code
in Delphi, 187 linked with Delphi,
207
declaration syntax, 73
assembly language, 234 80x87 emulation and, 152 call model, 207
inline
directives, 213
statements, 211 interfacing programs
with, 208 statements
multiple, 188
syntax, 192
Assign procedure, 139, 140,
145
AssignCrt procedure, 144,
145
assignment compatibility, 26
statement syntax, 55 assignment-compatibility
class-reference types, 109 automatic
call model selection, overriding, 174
data segment, 160 jump sizing, built-in
assembler, 189
word alignment, 184
AutoTracking variable, 143,
145
AX register, 173, 213
B
$B compiler directive, 46, 182, 227
base type, 21 binary
arithmetic operators, 44
operands, 41
operators, 13
binary format, 221
bitwise operators, 45
blanks, defined, 3 block
defined, 65
scope, 66
syntax, 65
BlockRead procedure, 139,
142
BlockWrite procedure, 139,
142
Boolean
data type, 14, 163 expression evaluation,
182
complete, 46
operators, 14
variables, 14 Boolean evaluation
compiler switch, 227
complete, 227
short circuit, 227 Boolean expression
evaluation
short-circuit, 46
Boolean operators, 45
BP register, 178
brackets, in expressions, 50 BufEnd variable, 167
buffer
BufPtr pointer, 167
BufSize variable, 167
Build command, 219
build command-line option, 219
built-in assembler directives, 187
expressions, 192
classes, 198 Object Pascal
expressions versus, 193
operators, 192
types, 201
instruction sizing, 189
opcodes, 189
operands, 192
procedures and functions, 203
reserved words, 192
BX register, 173 Byte data type, 12
ByteBool data type, 163
C
$C code segment attribute, 227
call model, 207
call models, 70 callbacks
smart, 71 calling
methods, 93
calling conventions, 171 constructors and destructors, 176
calls
near and far, 173 case
sensitivity of Turbo Pascal, 4
statement syntax, 58
Char data type, 14, 162 character
arrays, 155
pair special symbols, 4 pointer operators, 46 pointers
character arrays and, 155
indexing, 155
string literals and, 154
strings, 7
ChDir procedure, 139
CheckBreak variable, 145
CheckEOF variable, 144, 145
Chr function, 14, 181 class components
private, 90
protected, 90
public, 89
published, 89
scope, 88
visibility, 89
class domain, 87
class forward references, 88 class instances, 86
class methods, 87, 110
class of reserved words, 108 class reference types
constructors, 109
class references, 86
class reserved word, 88, 110 class type compatibility, 88 class types, 85
classes
ancestors, 87
components, 85
descendants, 87
inheritance, 87
scope, 88
class-reference types, 108 ClassType method function,
109
Close procedure, 139, 140,
145
CloseFile procedure, 146
ClrEol procedure, 144
ClrScr procedure, 144
CmdShow variable, 137 Code generation
Windows, 241
code segment, 208
attributes, 159
changing, 160 maximum size of, 159 procedures and functions
in, 207
Code segment attribute, 227 codesegs2, 159
command-line
compiler reference, 215
options, 215
/B, 219
/D, 218
debug, 221
/E, 221
/F, 219
/G, 221
/GD, 222
/GP, 222
/GS, 222
/I, 221
/L, 219
/M, 219
mode, 218
/O, 221
/Q, 220
switching directive defaults (/$), 217
/T, 220
/U, 221
/V, 222
command-line compiler arguments, 215 compiling and linking
with, 215
extended syntax, 217
options, 215
286 code generation,
216
align data, 216 append debug
information to EXE, 222
Boolean evaluation, 216
build all, 218, 219 build all units, 217 debug, 221
debug information, 216, 222
in EXE, 217
define conditional symbol, 217
DOS real-mode .EXE, 217
emulation, 216
EXE & DCU directory, 221
EXE and TPU directory, 217
find error, 219
find run-time error, 217
force far calls, 216 I/O checking, 216 include directories,
217, 221
link buffer, 218, 219
link buffer on disk, 217 list of, 216
local symbols, 216, 222
make, 219
make modified units, 217
map file, 217, 221
memory sizes, 216 numeric coprocessor,
216
object directories, 217,
221
open parameters, 216
overflow checking, 216
quiet compile, 217,
218, 220
range checking, 216 resource directories,
221
Smart callbacks, 216
stack checking, 216 TPL & CFG
directories, 217
TPL & CFG directory, 220
type-checked pointers, 216
unit directories, 217,
221
var-string checking, 216
Windows real-mode support, 216
symbol reference information, 217
comments, 7
built-in assembler, 188 common types of integer
types, 13
Comp data type, 16, 150, 165 comparing
character pointers, 48
packed strings, 48
pointers, 48
sets, 49
simple types, 48
strings, 48
values of real types, 151 compilation
conditional, 242 compiler
directives
$A, 226
$B, 46, 227
$C, 227
change state of, 217 conditional, 226
$D, 219, 228, 229
$DEFINE, 218, 229, 243
defined, 8
$ELSE, 229
$ENDIF, 230
$F, 24, 71, 174, 230
$G, 189, 231
$I, 233
$IFDEF, 232
$IFNDEF, 232
$IFOPT, 232
$K, 239
$L, 207, 208, 211, 233,
234
$L filename, 73, 152
$M, 30, 218, 235
$N, 16, 44, 189, 235
$P, 78, 235
parameter, 225
$R, 237
$S, 30, 137, 238, 239
switch, 225
$T, 26, 49
$UNDEF, 241, 243
$V, 241
$W, 241
$X, 230
$X, 7, 19, 22, 31, 46
$Y, 240
compiling
to .EXE file, 219 Complete Boolean Eval
option, 227 complete Boolean
evaluation, 46
compound statement syntax, 57
concatenation, 46 conditional
defines (command-line option), 218
symbols, 243 conditional statement
syntax, 57 configuration file
DCC.CFG, 222
CONST segment, 207 constant
address expressions, 36 declaration part syntax,
65
declarations, 9
expressions, 9
parameters, 76
constants, 9, 194
array-type, 37
folding, 181
merging, 181 numeric, built-in
assembler, 194
pointer-type, 39
procedural-type, 40
record-type, 38
set-type, 39
simple-type, 9, 36
string, built-in assembler, 194
string-type, 36
structured-type, 37
typed, 35
constructor reserved word, 94
constructors, 95
calling conventions, 176
class references, 109
defined, 87 control
characters, 7, 143
defined, 3 embedding in strings,
7
string syntax diagram, 7 CPU symbols, 244
creatfile, 219
creating objects, 95
CRT window, 142
closing, 143
scrolling, 143
CSEG segment, 208 current
file position, 140
file size, 140
Cursor variable, 145
CursorTo procedure, 144
D
$D compiler directive, 219, 228
$D description, 229
/D command-line option, 218
data
alignment, 184
ports, 169
segment, 207, 208
DLL, 137
maximum size, 30
data alignment, 226
DATA segment, 207
DCC.CFG file, 220, 222
sample, 223
dead code eliminated, 184 Debug Information
command, 228
option, 228 debugging
command-line option, 222
information switch, 228 options, command-line,
221
range-checking switch, 237
stack overflow switch, 239
decimal notation, 6
default array properties, 105 default directive, 105, 106
$DEFINE compiler directive, 218, 229, 243
defining properties, 102
access specifiers, 103
storage specifiers, 106
DELPHI.DSL, 220, 221 DEMANDLOAD code
segment attribute, 160 descendants
defined, 87
Description directive, 229 designators
field, 33
method, 33 destorying objects nil values, 97
Destroy method, 97
Destroy method versus Free method, 97
destroying objects, 96 destructor reserved word, 94 destructors, 96
calling conventions, 176
defined, 87 devices
drivers, 145
digit syntax diagram, 3 digits, defined, 3
direct memory, 168 directives
assembler, defined, 190
built-in assembler, 187,
203, 204
compiler, defined, 8
forward, 72
inline, 73
list of Borland Pascal, 4 private, 5
public, 5
standard, 4 directories
command-line options, 220
DISCARDABLE code
segment attribute, 160
div operator, 44 DLL
CmdShow variable, 137 contrasted with a unit,
129
data segment, 137
exit code, 135 files in a, 137
global memory in a, 137 global variables in, 137 gmem_DDEShare
attribute, 137
HeapLimit variable, 138
HPrevInst variable, 137
initalization code, 135
KERNEL, 130
multi-language programming, 129
PrefixSeg variable, 137 run-time errors in a, 138 structure of, 133
syntax, 133
unloading a, 136
using a, 130 domain
classes, 87
DoneWinCrt procedure, 143,
144
double address-of (@@) operator, 53
Double data type, 16, 150,
164
drivers
text-file device, 145
DS register, 178
DSEG segment, 207 DSL & CFG directory
command-line option, 220
DX register, 173 dynamic
importing, 132
linking, 129
variables, 30
dynamic directive, 92
dynamic methods, 92
dynamic variables, 21, 33 dynamic versus virtual
methods, 92
dynamic-link libraries, 129.
See also DLL
E
/E command-line option, 221
editing keys
in WinCrt unit, 144 eliminate dead code, 184
$ELSE compiler directive, 229
embedding control characters in strings, 7
empty set, 21
$ENDIF compiler directive, 230
end-of-line character, 3
entry code, 176, 203 enumerated
types, 14, 163
Eof function, 139
Eoln function, 139
Erase procedure, 139 error messages
searching, 219
ErrorAddr variable, 179 errors
range, 237
reporting, 178 examples
array type, 18
character strings, 7
constant expressions, 9,
10
control characters in strings, 7
enumerated type, 15
record type, 19
subrange type, 15
using subrange types, 15 variant part of a record,
20
EXE & DCU directory command-line option, 221
.EXE files
building, 185
.EXE files, creating, 219 exit
code, 203
in DLL, 136
functions, 176
procedures, 136, 137, 176,
178
far
call, 173
model
in imported procedures and function, 130
model, forcing use of, 178
Flush function, 146
Flush procedure, 139 for statement syntax, 61 Force Far Calls
command, 231
compiler directive, 230 formal
parameter list syntax, 75
ExitCode variable, 136, 179 exiting a program, 178 ExitProc variable, 136, 137,
178
exponents, 163
export directive, 134
exports clause, 134
syntax, 134
expression syntax, 41
expressions, 194, 199
built-in assembler, 192,
199
classes, 198
elements of, 196 versus Object Pascal,
193
constant, 9, 10
address, 36
order of evaluation, 182 types, built-in assembler,
200
Extended data type, 16, 150,
164
range arithmetic, 150
extended syntax, 7, 19, 22,
230
Extended Syntax option, 230 external
(reserved word), 211
declaration, 130
declarations, 234
directive, 204
in imported procedure and functions, 130
procedures and functions, 152, 207
EXTRN directive, 208
F
$F compiler directive, 24, 71,
far call model, forcing use of, 230
field
designators syntax, 33 list (of records), 19 record, 33
fields
object, 87 file. See also files
buffer, 167
handles, 166
modes, 166
types, 21
FilePos function, 139, 140 files
.ASM, 152
.OBJ, 207
functions for, 139
.MAP, 221
.OBJ, 221
linking with, 233
procedures for, 139
text, 141
typed, 166
types of, 166
untyped, 142, 166
files,, 274
FileSize function, 139, 140 Find Error command, 219 find error command-line
option, 219
finding the size of a given string, 17
FIXED code segment attribute, 159
fixed part of records, 19 floating-point
calculations, type Real and, 150
numbers, 16, 149
parameters, 50, 56 forward
declarations, 72
directive, 72
forward references, 88
Free method, 97
Free method versus Destroy method, 97
function
calls, 50
extended syntax and, 50
syntax, 50 declarations
assembler, 72
external, 72
headings, 74
results, 173
syntax, 74
functions, 69, 203. See also
procedures and calls, 171
discarding results, 230 entry/exit code, built-in
assembler, 203
extended syntax, 230
far, 174
near, 174
nested, 174 parameters, built-in
assembler, 203
private, 125
SizeOf, 79
stack frame for, built-in assembler, 203
standard
and constant expressions, 10
G
numeric coprocessor
145, 174, 230
/F command-line option, 219
False predefined constant identifer, 14
(80x87), 16
parameters, 172
software, 16
types, 150
floating-point,, 276
$G compiler directive, 189, 231
/G command-line option, 221
/GD command-line option, 222
GetDir procedure, 139
GetMem procedure, 33 global
heap in Windows, 161 memory in a DLL, 137 variables in a DLL, 137 gmem_DDEShare attribute,
137, 138
gmem_Moveable attribute, 138
goto statement syntax, 56 GotoXY procedure, 144
/GP command-line option, 222
Group unit segments compiler directive, 231
H
Halt procedure, 178 handles
file, 166 heap
management Windows, 161
fragmenting, 161
management, sizes, 218 manager
Windows, 161 allocating memory
blocks, 162
Windows global, 161
Windows local, 161 changing size of, 161 size of, 161
heap management, sizes, 235
I
$I compiler directive, 140, 233
I/O, 139
checking, 233
command, 233
devices, 145
error-checking, 140, 233
/I command-line option, 221 identifiers
as labels, 7
defined, 5
examples, 5
how identified in manuals, 5
length of, 5
qualified, 5
restrictions on naming, 5 scope of, 11
if statement syntax, 57
$IFDEF compiler directive, 232
$IFNDEF compiler directive, 232
$IFOPT compiler directive, 232
immediate values, built-in assembler, 198
implementation part of a unit, 125, 174
syntax, 125
import units, 131 importing procedures and
functions dynamically, 132
statically, 132
with import unit, 131
indexed properties, 104 indexes in arrays, 18 indexing character pointers,
155
indirect unit references, 126 infinite loop. See loop,
infinite
inherited reserved word, 88, 94
initialization
code in DLL, 135 part of a unit, 125
initialized variables, 35
in assembler, 207
InitWinCrt procedure, 143,
144
inline
directive, 73
directives, 213
statements, 211
InOut function, 146
Input text-file variable, 141 and WinCrt unit, 142
in WinCrt unit, 141 instances, 86
instruction opcodes, built-in assembler, 189
Integer data type, 12, 162
integer types, 14
interface part of a unit, 124, 174
interfacing=page, 208 internal data formats, 162 invalid
built-in assembler, 196
IOResult function, 139, 140
J
HeapAllocFlags variable,
in operator, 47, 49
138, 162
HeapBlock variable, 162
HeapLimit variable, 162
heapmanwin, 161
hex digits, 3 hexadecimal
constants, 6
numbers, 6
Hi function, 181
high bounds of index type of an array, 18
High function, 12, 18, 79 highest value in a range, 12 HInstance variable, 137
host type, 15
InactiveTitle variable, 145 Include directories
command-line option, 221,
233
include files, 221, 233
including resources, 237 index
clause, 130, 135
syntax, 32
types valid in arrays, 18 index directive, 105
index parameter list array properties, 104
index specifiers
property definitions, 105
jump sizing, automatic, built-in assembler, 189
K
$K compiler directive, 239 KERNEL dynamic-link
library, 130
KeyPressed function, 144
L
$L compiler directive, 207, 208, 211, 233, 234
$L filename compiler directive, 73, 152
/L command-line option, 219
label
declaration part syntax, 65
M
$M compiler directive, 30, 161, 218, 235
.MODEL directive, 208
multi-language programming and DLLs, 129
N
syntax, 6 /M command-line option,
labels
built-in assembler, 188
defined, 6 left
brace special symbol, 4 bracket special symbol, 4
Length function, 181 length of
a string-type value, 17 character strings, 7, 165
identifiers, 5
program lines, 8
record, 167
letters, defined, 3 libraries
dynamic-link, 129
library header, 133 line
input editing keys, 144 lines, maximum length of, 8 Link Buffer
option, 219 linking
buffer option, 219
dynamically, 129
object files, 233
smart, 185
statically, 129
Lo function, 181 local
labels, 189
local symbol information switch, 234
Local Symbols command, 234
option, 234 logical
operators, 45
LongBool data type, 14, 163 Longint data type, 12
loop, infinite. See infinite loop
low bounds of index type of an array, finding, 18
Low function, 12, 18, 79 lowest value in a range,
finding, 12
219
machine code in program, 211
Make command, 219
make command-line option, 219
map file command-line option, 221
.MAP files, 221
Mem array, 168
MemL array, 168 memory
allocation, 218
compiler directive, 235
model, 208
Object Pascal and, 159 references, built-in
assembler, 198
size, 235
MemW array, 168
metaclasses, 108
method activation, 93
method designator, 93 method identifiers
qualified, 94 methods
abstract, 92
assembly language, 211
calling, 93
class, 87, 110
constructors, 87
defined, 87
designators, 33
destructors, 87
dynamic, 92
external, 211
implementation, 93
overriding, 91
scope, 94
static, 90
virtual, 91
virtual versus dynamic, 92
MkDir procedure, 139
mod operator, 45
modular programming, 124 MOVEABLE code segment
attribute, 159
$N compiler directive, 44
$N compiler directive, 16, 189, 235
name clause, 130, 135 near
call, 173
nested procedures and functions, 24, 174
nesting include files, 233 New procedure, 21, 33
nil (reserved word), 21, 34 nil values
destroying objects, 97
nodefault directive, 106
not operator, 45
NULL Character, 153
null strings, 7, 17
null-terminated strings, 19
defined, 153
NULL Character, 153
pointers and, 154 standard procedures and,
157
number
constants, 6
syntax, 6 numbers
counting, 6, 162
hexadecimal, 6
integer, 6
real, 6 numeric
constants, built-in assembler, 194
coprocessor
emulating, assembly language and, 152
evaluation stack, 152 numeric coprocessor
compiler switch, 235
O
.OBJ files, 207
/O command-line option, 221
.OBJ files, 221
linking with, 233 object
component designators, 33
directories, compiler directive, 233
files, 207
files, linking with, 233 object directories command-
line option, 221
object reference, 86
object types. See also objects objects
creating, 95
defined, 86
destroying, 96
fields, 87
designators, 33
files in $L directive, 208 methods, 87
referencing, 86
scope, 67
Odd function, 181
opcomp, 181
Open function, 146
open parameters, 76, 78
array, 19, 76, 79
how passed, 172
string, 17, 78
open string parameters compiler switch, 235
OpenString identifier, 17
operands, 41, 192
built-in assembler, 192 operators
string, 46 structure member
selector, 198
types of, 44
unary arithmetic, 44
xor, 45
or operator, 45
Ord function, 12, 14, 15, 181 order of evaluation, 183 ordering between two string-
type values, 17 ordinal
types
predefined, 12
user-defined, 12 ordinality
defined, 12
enumerated constant, 15 finding enumerated
type's value, 15
returning, 12
Char values, 14
Origin variable, 145 Output text-file
in WinCrt unit, 141 Output text-file variable, 141
and WinCrt unit, 142 overflow checking, 236
override directive, 91
overriding methods, 91
overriding properties, 107
P
passing parameters by reference, 171
by value, 171
passing parmeters, 171 passing string variables of
varying sizes, 17 PChar data type, 22
PERMANENT code segment attribute, 160
pointer (^) symbol, 21, 22, 33 Pointer data type, 22 pointers
comparing, 48
types, 21, 165
values, 33
variables, 33
pointer-type constants, 39
Port array, 169
ports, accessing, 169
PortW array, 169 pound (#) character, 7
precedence of operators, 41, 44
precision
of real-type values, 16 rules of arithmetic, 13
Pred function, 12, 181 predecessor of a value,
returning, 12
PrefixSeg variable, 137 PRELOAD code segment
attribute, 160 private
@ (address-of), 21, 34, 49, directive, 5
52
@@ (double address-of), 53
and, 45
arithmetic, 44
binary arithmetic, 44
bitwise, 45
Boolean, 45
character-pointer, 46
div, 44
logical, 45
mod, 45
not, 45
or, 45
precedence of, 41, 44
built-in assembler, 201
relational, 47
set, 47
shl, 45
shr, 45
$P compiler directive, 78, 235
packed
reserved word, 17
string type, 18
strings, comparing, 48 parameters
actual, 56
constant, 76
floating-point, 172
formal, 56
open, 78
array, 79
string, 78
passing, 56
types, 75
untyped, 77
value, 76, 172
variable, 77
virtual method, 176
procedures and functions, 125
private sections classes, 90
PROC directive, 208 procedural
types
type compatibility of, 24
variable typecasts, 35 procedural-type constants,
40
procedure
declaration syntax, 69 declarations
assembler, 72
external, 72
forward, 72
inline, 73
headings, 70
statements, 56 procedure and function
declaration part, 66
classes, 89
Q
recursive loop. See recursive loop
redeclaration of variables, 29
procedures, 69. See also references
procedures and entry/exit code, built-in
assembler, 203
exit, 137
external, 152
far, 174
near, 174
nested, 174 parameters, built-in
assembler, 203 stack frame, built-in
assembler, 203 procedures and functions.
See also procedures; functions
importing, 130
nested, 24
written in assembler, 207 call model, 207
program
comments, 7
heading, 123
lines, maximum length of, 8
parameters, 123
syntax, 123
termination, 178 programs
rebuilding, 219
properties, 101
access, 102
array, 104
defined, 87
definitions, 102
index specifiers, 105
overrides, 107
storage specifiers, 106
overriding, 107
property override, 107 protected sections
classes, 90
Ptr function, 21, 33, 181 public
directive, 5
procedures and functions, 124
PUBLIC directives, 207 public sections
classes, 89 published sections
/Q command-line option, 220
qualified
identifiers, 5 method
identifiers, 33, 50 qualified method identifer,
94
qualifier syntax, 32
quiet mode command-line option, 220
R
$R compiler directive, 237
$R filename directive, 237 range
checking, 156
compile-time, 184 finding higest value, 12 finding lowest value, 12 of real-type values, 16
range checking, 217
command, 237
compiler switch, 237
option, 237
read directive, 102 Read procedure
for values not of type Char, 141
text files, 139, 140
ReadBuf function, 144
ReadKey function, 144
Readln procedure, 139 real
data types, 16
numbers, 16, 149, 163 Real data type, 16
real-type operations 80x87 floating type, 16
software floating point, 16
record
scope, 67
types, 19
records, 19, 33, 38, 166
fields, 33
variant part, 19
record-type constant syntax, 38
class, 86 registers
and inline statements, 212 AX, 173, 213
BP, 178
built-in assembler, 195,
198
BX, 173
DS, 178
DX, 173
SP, 178
SS, 178
use, built-in assembler, 188
using, 173, 178, 188
register-saving conventions, 178
regs, 195
relaxed string parameter checking, 241
relocation expressions, built- in assembler, 199
Rename procedure, 139 repeat statement syntax, 59 repetitive statement syntax,
59
reserved words, 4
built-in assembler, 192
defined, 4
external, 211 how identified in
manuals, 4
list of, 4
Reset procedure, 139, 140 resident option in exports
clause, 135 Resource directories
command-line option, 221
resource file, 237 resources
including, 237
RET instruction, built-in assembler, 189
RETF instruction, built-in assembler, 189
RETN instruction, built-in assembler, 189
return character, defined, 3 returning
Char values, 14
the ordinality of a value, 12
the predecessor of a value, 12
the successor of a value, 12
Rewrite procedure, 139, 140 right
brace special symbol, 4 bracket special symbol, 4
RmDir procedure, 139
Round function, 181 rules
governing boolean variables, 14
run-time
errors, 178
in a DLL, 138 run-time errors
Find Error command and, 219
finding, 219
run-time type information, 89
S
$S compiler directive, 30, 137, 238, 239
scale factor syntax diagram, 6
scope
block, 66
class, 88
object, 67
record, 67
rules of, 66
type identifiers, 11
unit, 67
within methods, 94
ScreenSize variable, 143, 145
ScrollTo procedure, 144
Seek procedure, 139, 140
SeekEof function, 139
SeekEoln function, 140 segment
attributes, 159
sub-allocator, 161 Segment size compiler
directive, 238
segments, 207
Self identifer, 87
Self identifier, 110
Self parameter, 176
separating tokens, 3
separators, defined, 3 set
constructors syntax, 50 membership testing, 49
operators, 47
types, 20, 165
set constructors, 42 sets. See also set
comparing, 49
small, 183
SetTextBuf procedure, 140
set-type constants, 39
Shift instructions faster than multiply or divide, 184
shl operator, 45 short-circuit Boolean
evaluation, 46, 182, 227 Shortint data type, 12 shr operator, 45
signed number syntax diagram, 6
significand, 163 simple
expression syntax, 43
statement syntax, 55 types
comparing, 48
simple-type constants, 36 single character special
symbols, 4
Single data type, 16, 150, 164 size
of a given string, finding, 17
of structured types, maximum, 17
SizeOf function, 79
small sets, 183
smart callbacks, 71, 239
smart linking, 185 software
floating-point model, 16
restrictions, 16 source debugging compiler
switch, 228
SP register, 178
space characters, 3 special symbols
built-in assembler, 196 character pairs listed, 4
single characters listed, 4 SS register, 178
stack, 161
80x87, 152
changing size of, 161 checking, 137
checking switch directive, 239
frame, built-in assembler use of, 203
overflow, 30
switch directive, 239 passing parameters and,
171
segment, 30
DLLs and, 138
size, 235 Stack Checking
command, 239
option, 239
standard, 139
directives, 4 procedure or function
used as a procedural value, 24
statement part syntax, 66 statements, 55
assignment, 55
case, 58
compound, 57
conditional, 57
for, 61
goto, 56
if, 57
procedure, 56
repeat, 59
repetitive, 59
simple, 55
structured, 57
while, 60
with, 62 static
data area, 161
importing, 132
linking, 129
static methods, 90
storage specifiers, 106
stored directive, 106 storing
null-terminated strings, 19
strict string parameter checking, 241
string. See also strings
constants, built-in assembler, 194
literals, assigning to PChar, 154
operator, 46 type
default size, 17
defined, 17
ordering between two values, 17
packed, 19
typed constants, 36
variables, 32 String Var Checking
command, 241
option, 241 string variables
passing, 17 strings. See also string
character, 7
length of, 7
comparing, 48
concatenating, 46 embedding control
characters in, 7
length byte, 165
maximum length, 165
null, 7, 17
null-terminated, 19 relaxed parameter checking of, 241
strict parameter checking of, 241
types, 165
Strings unit, 153
structure member selector operator, 198
structured
statement syntax, 57
structured types, 17
structured-type constants, 37
subrange type, 15
Succ function, 12, 181 successor of a value,
returning, 12
Swap function, 181
switch compiler directives, 225
symbol reference compiler switch, 240
symbols, 3, 196
built-in assembler, 196
conditional, 243
CPU, 244
invalid, built-in assembler, 196
list of special, 4
local information, 234 reserved, built-in
assembler, 195 scope access, built-in
assembler, 198 special, built-in assembler, 196
syntax
extended, 230
System unit, 123
T
$T compiler directive, 26, 49
/T command-line option, 220
tag field, 20
task header, 160
TClass type, 111
term syntax, 43
terminating, 178 testing
set membership, 49 text
files, 141
devices
drivers, 145
Text type, 141
TObject class, 88
Destroy method, 97
Free method, 97
TObject type, 111
tokens, 3
categories of, 3
defined, 3
separating, 3
TrackCursor procedure, 144 trapping I/O errors, 233 True predefined constant
identifier, 14
Trunc function, 181
Truncate procedure, 140
TTextRec records, 145, 166
Turbo Assembler, 208
80x87 emulation and, 152 type. See also types
declaration, 11 declaration part syntax,
66
identifier, 11 type checking
strings and, 241 type checking, built in
assembler, 200 typecasting integer-type
values, 14
typecasts, value, 34, 51 typed
constant
syntax, 35
files, 166 types
array, 18, 166
boolean, 14, 163
Byte, 12
ByteBool, 163
Char, 14, 162
class, 85
class reference, 108
Comp, 12, 150
compatibility, 24, 25
declaration part, 27
Double, 12, 150
enumerated, 14, 163
Extended, 12, 150
file, 21
floating-point, 16, 150,
163
Comp, 165 comparing values of,
151
Double, 164
Extended, 164
Single, 164
host, 15
identical, 24
identity, 25
Integer, 12, 162 converting through
typecasting, 14
format of, 13
range of, 13
LongBool, 14, 163
Longint, 12
major classes, 11 ordinal
characteristics of, 12
predefined, 12
user-defined, 12
packed string, 19
PChar, 22
Pointer, 21, 22, 165
procedural, 52
Real, 12, 16
real numbers, 163
record, 19, 166
set, 20, 165
Shortint, 12
Single, 12, 150
string, 17, 165
subrange, 15
Text, 141
Word, 12
WordBool, 14, 163
U
/U command-line option, 221
unary
arithmetic operators, 44
operands, 41
$UNDEF compiler directive, 241, 243
Unit Directories option, 221
Unit segment grouping compiler directive, 231
unit syntax, 124 units
heading, 124
identifiers, 5
implementation part, 125
import, 131
indirect references, 126
initialization part, 125
interface part, 124
scope of, 67
Strings, 153
unit directories option, 221
uses clause, 123
version number, 126
WinCrt, 142 unsigned
constant syntax, 42 integer syntax diagram, 6 number syntax diagram,
6
real syntax diagram, 6 untyped
files, 142, 166
parameters, 77
uses clause, 123
V
$V compiler directive, 241
/V command-line option, 222
value
parameters, 76, 172
typecast syntax, 51 var
declaration section, 185
parameters, 77, 171
built-in assembler and, 197
string checking compiler switch, 241
variable. See also variables declaration part syntax,
66
declaration syntax, 29
parameters, 77 reference
qualifiers, 31
syntax, 31
typecasts, 34
and procedural types, 35
syntax, 34 variables
absolute, 30
array, 32
declarations, 29
dynamic, 21, 33
global, 30
initialized in assembler, 207
initializing, 35
local, 30
parameters, 171
pointer, 33
record, 33
references, 31
string, 32
variant part of records, 19 VER80 symbol, 244 virtual
method
parameter, 176
virtual directive, 91
virtual methods, 91 virtual versus dyanmic
methods, 92 visibility of class
components, 89
W
$W compiler directive, 241 WEP exported function, 136
wep_Free_DLL value for ExitCode, 136
wep_System_Exit value for ExitCode, 136
WhereX function, 144
WhereY function, 144 while statement syntax, 60 wincrt, 142
WinCrt unit, 141, 142 editing keys in, 144 using the, 142
variables in, 144 windows stack frames, 241 Windows symbols, 244
WindowSize variable, 145
WindowTitle variable, 145
WinOrg variable, 144 with statement syntax, 62 with statements, 88, 93
word alignment, automatic, 184
Word data type, 12 WordBool data type, 14, 163
write directive, 102
Write procedure, 140 for values not of type
Char, 141
WriteBuf procedure, 144
WriteChar procedure, 144
Writeln procedure, 140
X
$X compiler directive, 7, 19,
22, 31, 46, 230
xor operator, 45
Y
$Y compiler directive, 240
Z
zero-based character arrays, 37, 153, 155
Object Pascal Language Guide
Delphi
Borland International, Inc., 100 Borland Way
P.O. Box 660001, Scotts Valley, CA 95067-0001
Borland may have patents and/or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents.
Copyright © 1995 Borland International. All rights reserved. All Borland products are trademarks or registered trademarks of Borland International, Inc. Other brand and product names are trademarks or registered trademarks of their respective holders.
Printed in the U.S.A.
1E0R395
9596979899-9 8 7 6 5 4 3 2 1
W1
Contents
Introduction 1
What’s in this manual? 1
Syntax Diagrams 1
Chapter 1
Tokens 3
Special symbols 3
Reserved words and standard directives 4
Identifiers 5
Numbers 6
Labels 6
Character strings 7
Comments 7
Program lines 8
Chapter 2
Constants 9
Chapter 3
Types 11
Simple types 11
Ordinal types 12
Integer types 12
Boolean types 14
Char type 14
Enumerated types 14
Subrange types 15
Real types 16
80x87 floating point 16
Software floating point 16
String types 17
Structured types 17
Array types 18
Record types 19
Set types 20
File types 21
Pointer types 21
Type Pointer 22
Type PChar 22
Procedural types 22
Global procedure pointers 22
Method pointers 23
Procedural values 23
Procedural type compatibility 24
Identical and compatible types 24
Type identity 25
Type compatibility 25
Assignment compatibility 26
The type declaration part 27
Chapter 4
Variables and typed constants 29
Variable declarations 29
The data segment 30
The stack segment 30
Absolute variables 30
Variable references 31
Qualifiers 32
Arrays, strings, and indexes 32
Records and field designators 33
Object component designators 33
Pointers and dynamic variables 33
Variable typecasts 34
Typed constants 35
Simple-type constants 36
String-type constants 37
Structured-type constants 37
Array-type constants 37
Record-type constants 38
Set-type constants 39
Pointer-type constants 39
Procedural-type constants 40
Chapter 5
Expressions 41
Expression syntax 41
Operators 44
Arithmetic operators 44
Logical operators 45
Boolean operators 45
String operator 46
Character-pointer operators 46
Set operators 47
Relational operators 47
Comparing simple types 48
Comparing pointers and references 48
Comparing character pointers 48
@ with a procedure, function, or method 50
Procedural types in expressions 52
Statements 55
Blocks, locality, and scope 65
Assembler declarations 73
Type variant open-array parameters 81
Forward references 88
Class type compatibility rules 88
Constructors and destructors 94
Message handler declarations 99
Message handler implementations 99
Access specifiers 103
Constructors and class references 109
The TObject and TClass types 111
The try...except statement 115
Nested exceptions 118
The try...finally statement 119
Exit, Break, and Continue procedures 120
Exception handling support routines 122
The program heading 123
Static and dynamic imports 132
The export procedure directive 134
Library initialization code 135
Global memory and files in a DLL 137
Input and output with the WinCrt unit 142
WinCrt procedures and functions 144
The 80x87 evaluation stack 152
Emulation in assembly language 152
Using null-terminated strings 153
What is a null-terminated string? 153
Using null-terminated strings 153
Character pointers and string literals 154
Character pointers and character arrays155 Character pointer indexing 155
Null-terminated strings and standard procedures 157
Chapter 16
Memory issues 159
Windows memory management 159
Code segments 159
Segment attributes 159
MOVEABLE or FIXED 159
PRELOAD or DEMANDLOAD 160
DISCARDABLE or PERMANENT160
Changing attributes 160
The automatic data segment 160
The heap manager 161
Internal data formats 162
Integer types 162
Char types 162
Boolean types 163
Enumerated types 163
Floating-point types 163
The Real type 163
The Single type 164
The Double type 164
The Extended type 164
The Comp type 165
Pointer types 165
String types 165
Set types 165
Array types 166
Record types 166
File types 166
Procedural types 167
Class types 167
Class reference types 168
Direct memory access 168
Direct port access 169
Chapter 17
Control issues 171
Calling conventions 171
Variable parameters 171
Value and constant parameters 172
Open parameters 172
Function results 173
NEAR and FAR calls 173
Nested procedures and functions 174
Method calling conventions 175
Constructors and destructors 176
Entry and exit code 176
Register-saving conventions 178
Exit procedures 178
Chapter 18
Optimizing your code 181
Constant folding 181
Constant merging 181
Short-circuit evaluation 182
Constant parameters 182
Redundant pointer-load elimination 182
Constant set inlining 183
Small sets 183
Order of evaluation 183
Range checking 184
Shift instead of multiply or divide 184
Automatic word alignment 184
Eliminating dead code 184
Smart linking 185
Chapter 19
The built-in assembler 187
The asm statement 187
Register use 188
Assembler statement syntax 188
Labels 188
Instruction opcodes 189
RET instruction sizing 189
Automatic jump sizing 189
Assembler directives 190
Operands 192
Expressions 193
Differences between Object Pascal and Assembler expressions 193
Expression elements 194
Constants 194
Numeric constants 194
String constants 194
Registers 195
Symbols 196
Expression classes 198
Expression types 200
Expression operators 201
Assembler procedures and functions 203
Chapter 20
Linking assembler code 207
Turbo Assembler and Delphi 208
Examples of assembly language routines 209 Assembly language methods 211
Inline machine code 211
Inline statements 211
Inline directives 213
Appendix A
The command-line compiler 215
Command-line compiler options 215
Compiler directive options 217
The switch directive option 217
The conditional defines option 218
Compiler mode options 218
The make (/M) option 219
The build all (/B) option 219
The find error (/F) option 219
The link buffer (/L) option 219
The quiet (/Q) option 220
Directory options 220
The DSL & CFG Directory (/T)
option 220
The EXE & DCU directory (/E)
option 221
The include directories (/I) option 221
The unit directories (/U) option 221
The resource directories (/R)
option 221
The object files directories (/O)
option 221
Debug options 221
The map file (/G) option 221
The debugging (/V) option 222
The DCC.CFG file 222
Appendix B
Compiler directives 225
Align data 226
Boolean evaluation 227
Code segment attribute 227
Debug information 228
DEFINE directive 229
Description 229
ELSE directive 229
ENDIF directive 230
Extended syntax 230
Force Far calls 230
Generate 80286 Code 231
Group unit segments 231
IFDEF directive 232
IFNDEF directive 232
IFOPT directive 232
Include file 233
Input/output checking 233
Link object file 233
Local symbol information 234
Memory allocation sizes 235
Numeric coprocessor 235
Open String Parameters 235
Overflow checking 236
Pentium safe FDIV operations 236
Range checking 237
Resource file 237
Run-time type information 238
Segment size preference 238
Smart callbacks 239
Stack-overflow checking 239
Symbol reference information 240
Type-checked pointers 240
UNDEF directive 241
Var-string checking 241
Windows stack frames 241
Word sized enumeration types 242
Using conditional compilation directives.242 Conditional symbols 243
Appendix C
Error Messages 245
Compiler error messages 245
Run-time errors 273
File errors 273
I/O errors 275
Fatal errors 275
Index 277
Tables
-
Object Pascal reserved words 4
-
Object Pascal directives 5
-
Fundamental integer types 13
-
Generic integer types for 16-bit implementations of Object Pascal 13
-
Generic integer types for 32-bit implementations of Object Pascal 13
-
Real data types 16
-
Precedence of operators 41
-
Binary arithmetic operations 44
-
Unary arithmetic operations 44
-
Logical operations 45
-
Boolean operations 45
-
String operation 46
-
Permitted PChar constructs 47
-
Set operations 47
-
Relational operations 47
8-1 Type variant open-array expressions83
-
Predefined exception classes 121
-
Exception support routines 122
-
Input and output procedures and functions 139
-
Special characters in the WinCrt window 143
-
WinCrt procedures and functions 144
-
WinCrt variables 144
16-1 Virtual Method Table layout 168
-
Built-in assembler reserved words .192
-
String examples and their values 195
-
CPU registers 195
-
Values, classes, and types of symbols 197
-
Predefined type symbols 201
-
Summary of built-in asssembler expression operators 201
-
Definitions of built-in assembler expression operators 202
A-1 Command-line options 216
B-1 TestFDIV values 237
C ontents 1
2 Objec t Pas c a l Language Guide