Turbo Pascal Version 7.0 Programmers Reference 1992
Turbo Pascal Version 7.0 Programmers Reference 1992
PROGRAMMER'S
REFERENCE
RUNTIME LIBRARY
COMMANDlINE COMPILER
ERROR MESSAGES
COMPILER DIRECTIVES
BORLAND
Turbo PascafB>
Version 7.0
Programmer's Reference
Rl
Introduction
1
What's in this manual? ................. 1
How to contact Borland . . . . . . . . . . . . . . .. 2
Chapter 1 Library reference
5
Sample procedure . . . . . . . . . . . . . . . . . . . .. 5
Abs function ......................... 6
Addr function ........................ 6
Append procedure . . . . . . . . . . . . . . . . . . .. 6
ArcCoordsType type .................. 7
Arc procedure . . . . . . . . . . . . . . . . . . . . . . .. 8
ArcTan function ...................... 8
Assign procedure ..................... 9
AssignCrt procedure ................. 10
Assigned function . . . . . . . . . . . . . . . . . . .. 10
Bar constants . . . . . . . . . . . . . . . . . . . . . . .. 11
Bar procedure ....................... 11
Bar3D procedure ..................... 12
BitBlt operators .. . . . . . . . . . . . . . . . . . . .. 12
BlockRead procedure . . . . . . . . . . . . . . . .. 13
BlockWrite procedure ................ 14
Break procedure ..................... 15
ChDir procedure ............. " ...... 15
CheckBreak variable ................. 16
CheckEOF variable . . . . . . . . . . . . . . . . . .. 16
CheckSnow variable ............... ~ ". 16
Chr function ........................ 17
Circle procedure ..................... 17
ClearDevice procedure ............... 18
ClearViewPort procedure ............. 19
Clipping conshints ................... 19
Close procedure ..................... 20
CloseGraph procedure . . . . . . . . . . . . . . .. 20
ClrEol procedure .................... 21
ClrScr procedure ...... '.' . . . . . . . . . . . .. 21
Color constants .. . . . . . . . . . . . . . . . . . . .. 22
22
23
23
24
25
25
25
26
26
27
27
27
28
28
29
30
30
30
31
32
32
32
33
35
35
36
36
36
37
37
38
39
39
39
40
41
ExitProc variable . . . . . . . . . . . . . . . . . . . ..
Exp function .............. ;.........
fcXXXX flag constants ................
FExpand function ..................... '
File attribute constants . . . . . . . . . . . . . . ..
File name length constants ............
FileExpand function . . . . . . . . . . . . . . . . ..
File-handling string types ............
FileMode variable . . . . . . . . . . . . . . . . . . ..
FilePos function .....................
FileRec type . . . . . . . . . . . . . . . . . . . ... . . ..
FileSearch function . . . . . . . . . . . . . . . . . ..
FileSize function .............. . . . . . ..
FileSplit function. '.' ................. :
Fill pattern constants .................
FillChar procedure ... . . . . . . . . . . . . . . ..
FillEllipse procedure ..' ...............
FillPatternType type . . . . . . . . . . . . . . . . ..
FillPoly procedure ...................
FillSettingsType type .................
FindFirst procedure ..................
FindNext procedure . . . . . . . . . . . . . . . . ..
Flag constants .......................
FloodFill procedure ..................
Flush procedure .....................
fmXXXX constants ...................
Font control constants ................
F~ac function ................. : . . . . ..
FreeList variable .....................
FreeMem procedure . . . . . . . .. .. . . . . . ..
FSearchfunction . . . . . . . . . . . . . . . . . . . ..
FSplit procedure .....................
GetArcCoords procedure ............ ,
GetArgCount function . . . . . . . . . . . . . . ..
GetArgStr function . . . . .. . . . . . . . . . . . ..
GetAspectRatio procedure ............
GetBkColor function .................
GetCBreak procedure. . . . . . . . . . . . . . . ..
GetColor function . . . . . . . . . . . . . . . . . . ..
GetCurDir function ..................
GetDate procedure . . . . . . . . . . . . . . . . . ..
GetDefaultPalette function ............
GetDir procedure ....................
GetDriverName function. . . . . . . . . . . . ..
41
42
42
42
43
43
44
44
45
45
46
46
47
47
48
49
49
50
50
51
51
52
53
53
54
55
55
55
56
56
57
57
58
59
59
59
60
61
62
62
63
63
64
64
iii
117
117
117
118
118
118
119
119
120
120
120
121
122
122
123
123
123
124
125
125
125
126
126
127
127
127
128
128
129
129
129
130
132
132
133
133
133
135
135
136
136
137
139
141
141
142
142
143
144
145
145
146
146
147
148
149
149
149
150
150
150
151
151
151
152
152
154
155
155
156
156
157
157
158
159
160
160
160
161
162
163
164
168
169
169
171
171
172
iv
172
173
174
175
176
176
177
177
177
177
177
178
178
179
179
180
180
181
181
181
182
182
183
183
184
184
185
185
186
186
187
187
188
188
188
189
189
190
190
191
192
192
193
193
194
195
196
196
197
198
198
198
199
199
200
200
200
201
202
202
202
203
203
204
206
206
209
211
211
212
212
213
213
213
214
214
215
215
215
215
216
216
216
217
218
218
218
219
219
220
220
221
221
222
222
222
223
224
237
237
257
258
260
261
vi
275
277
Index
281
vii
viii
This manual is a reference that you can keep nearby when you're
programming. Use it when you want to
Look up the details of a particular run-time library procedure,
function, variable, type, or constant and find out how to use it
Understand what each compiler directive does, how it works,
and how to use it
Learn how to use the command-line compiler
Find out what an error message means
Look up editor commands
Look up compiler directives in a quick reference table
Review a list of reserved words and standard compiler
directives
Look up ASCII alphanumeric characters, symbols, and control
instructions
command-line compiler.
Chapter 4: Error messages lists in numerical order all the error
messages you might encounter and explains what they mean.
Introduction
800-822-4269 (voice)
Programmer's Reference
Service
Command
CompuServe GO BORLAND
BIX
JOIN BORLAND
GEnie
BORLAND
Introduction
Programmer's Reference
1
Library reference
This chapter contains a detailed description of all Turbo Pascal
procedures, functions, variables, types, and constants. At the
beginning of each alphabetically listed entry is the name of the
unit or units containing the data element or routine, followed by
the purpose, the declaration format, and any remarks specifically
related to that entry. If any special restrictions apply, these are
also described. The cross-referenced entries and examples provide
additional information about how to use the specified entry. The
first sample procedure illustrates this format.
Sample procedure
Purpose
Declaration
Remarks
Restrictions
Unit it occupies
Description of purpose.
How the data element or routine is declared; user-defined entries are
italicized. Tables instead of declarations are used to illustrate constants
whose values cannot be changed.
Specific information about this entry.
Special requirements that relate to this entry.
See also
Related variables, constants, types, procedures, and functions that are also
described in this chapter.
Example
A sample program that illustrates how to use this entry. In cases where
the same function (for example, DiskFree) is included in more than one
Abs function
unit (for example, the Dos and WinDos units), separate program examples
are listed only if significant differences exist between the two versions.
Abs function
Purpose
Declaration
System
Returns the absolute value of the argument.
function Abs (X) ;
Remarks
Example
var
r: Real;
i: Integer;
begin
r := Abs(-2.3);
i : = Abs (-157) ;
end.
Addr function
Purpose
Declaration
System
Returns the address of a specified object.
function Addr (X): Pointer;
Remarks
See also
Example
var P: Pointer;
begin
P : = Addr (P) ;
end.
Append procedure
Purpose
Declaration
Remarks
{ 2.3 }
{ 157 }
System
F is a text file variable that must have been associated with an external file
using Assign.
Programmer's Reference
Append procedure
Append opens the existing external file with the name assigned to F. An
error occurs if no external file of the given name exists. If F is already
open, it is closed, then reopened. The current file position is set to the end
of the file.
If a Ctrl+Z (ASCII 26) is present in the last 128-byte block of the file, the
current file position is set to overwrite the first Ctrl+Z in the block. In this
way, text can be appended to a file that terminates with a Ctrl+l.
If F was assigned an empty name, such as Assign(F, "), then, after the call
to Append, F refers to the standard output file (standard handle number 1).
After a call to Append, F becomes write-only, and the file pointer is at endof-file.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
See also
Example
var F:Text;
begin
Assign{F, 'TEST.TXT');
Rewrite (F) ;
Writeln{F, 'original text');
Close (F) ;
Append (F) ;
Writeln{F, 'appended text');
Close (F) ;
end.
ArcCoordsType type
Purpose
Declaration
See also
Graph
GetArcCoords
Arc procedure
Arc procedure
Draws a circular arc from a starting angle to an ending angle.
Purpose
Declaration
Remarks
Graph
Draws a circular arc around (X, Y), with a radius of Radius from StAngle to
EndAngle in the current drawing color.
Each graphics driver contains an aspect ratio used by Circle, Are, and
PieS lice. A start angle of 0 and an end angle of 360 draws a complete circle.
The angles for Are, Ellipse, and PieS lice are counterclockwise with 0
degrees at 3 0' clock, 90 degrees at 12 0' clock, and so on. Information about
the last call to Arc can be retrieved by GetArcCoords.
Restrictions
See also ' Circle, Ellipse, FillEllipse, GetArcCoords, GetAspectRatio, PieS lice, Sector,
SetAspectRatio
Example
uses Graph;
var
Gd, Gm: Integer;
Radius: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt(l) ;
for Radius := 1 to 5 do
Arc(100, 100, 0, 90, Radius * 10);
Readln;
CloseGraph;
end.
ArcTan function
Purpose
Declaration
System
Remarks
See also
Cos, Sin
Programmer's Reference
ArcTan function
Example
var R: Real;
begin
R := ArcTan (Pi) ;
end.
Assign procedure
Purpose
Declaration
Remarks
System
Drive is a disk drive identifier (A-Z). If Drive and the colon are omitted,
the default drive is used. \DirName\ ... \ DirName is the root directory and
subdirectory path to the file name. FileName consists of a name of up to
eight characters, optionally followed by a period and an extension of up to
three characters. The maximum length of the entire file name is 79
characters.
A special case arises when Name is an empty string, that is, when
Length(Name) is zero. In that case, F becomes associated with the standard
input or standard output file. These special files allow a program to utilize
the I/O redirection feature of the DOS operating system. If assigned an
empty name, then after a call to Reset(F), F refers to the standard input file,
and after a call to Rewrite(F), F refers to the standard output file.
Restrictions
See also
Example
{Try redirecting this program from DOS to PRN, disk file, etc. }
var F: Text;
begin
Assign(F, ");
{ Standard output }
Assign procedure
Rewrite (F) ;
Writeln(F, 'standard output ... ');
Close(F);
end.
AssignCrt procedure,
Purpose
Declaration
Remarks
Crt
This allows faster output (and input) than would normally be possible
using standard output (or input).
Example
uses Crt;
var F: Text;
begin
Write('Output to screen or printer [S, P]? ');
if UpCase(ReadKey) = 'P' then
Assign(F, 'PRN')
{ Output to printer }
else
AssignCrt(F);
{ Output to screen, use fast CRT routines}
Rewrite (F) ;
Writeln(F, 'Fast output via CRT routines ... ');
Close(F);
end.
System
Assigned function
Purpose
Declaration
Remarks
Example
var P: Pointer;
begin
P := nil;
10
Programmer's Reference
Bar constants
Bar constants
Graph
Purpose
Remarks
Used by the Bar3D procedure to control whether to draw a top on' 3-D
bars.
See also
Constant
Value
Top On
TopOf!
True
False
Bar3D
Bar procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Draws a filled-in rectangle (used in bar charts, for example). Uses the
pattern and color defined by SetFillStyle or SetFillPattern. To draw an
outlined bar, call Bar3D with a depth of zero.
Must be in graphics mode.
See also
Example
uses Graphi
var
Gd; Gm: Integeri
I, Width: Integeri
begin
Gd := Detecti
InitGraph(Gd, Gm, ")i
if GraphResult <> grOk then
Halt(l) ;
Width := 10i
for I := 1 to 5 do
Bar(I * width, I * 10, Suce(I) * Width, 200)
Readln;
CloseGraph;
end.
11
Bar3D procedure
Bar3D procedure
Purpose
Declaration
Remarks
Graph
Draws a 3-D bar using the current fill style and color.
procedure Bar3D(X1, Yl, X2, Y2: Integer; Depth: Word; Top: Boolean);
Restrictions
1) div 4, TopOn);
See also
Example
uses Graph;
var
Gd, Gm: Integer;
YO, Yl, Y2, Xl, X2: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt(l);
YO := 10;
Yl := 60;
Y2 : = 110;
Xl := 10;
X2 := 50;
Bar3D(Xl, YO, X2, Yl, 10, TopOn);
Bar3D(Xl, Yl, X2, Y2, 10, TopOff);
Readln;
CloseGraph;
end.
BitBlt operators
Purpose
Graph
Remarks . The following constant values represent the indicated logical operations.
12
Programmer's Reference
BitBlt operators
Constant
Value
CopyPut
XORPut
o (mov)
II
1 (xor)
2(or)
3 (and)
4 (not)
BlockRead procedure
Purpose
Declaration
Remarks
System
BlockRead.
With {$I-}, IOResult returns 0 if the operation succeeded; otherwise, it
returns a nonzero error code.
Restrictions
See also
BlockWrite
13
BlockRead prc;>cedure
Example
program CopyFile;
{ Simple, fast file copy program with NO error-checking }
var
FromF, ToF: file;.
NumRead, NumWritten: Word;
Buf: array[1 .. 2048] of Char;
begin
Assign (FromF, ParamStr(l));
Reset (FromF, 1);
Assign(ToF, ParamStr(2));
Rewrite (ToF, 1);
Writeln('Copying " FileSize(FromF), , bytes ... ');
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
Close (FromF) ;
Close (ToF) ;
end.
BlockWrite procedure
Purpose
Declaration
Remarks
}
}
}
}
System
14
Programmer's Reference
BlockWrite procedure
II
See also
BlockRead
Example
System
Break procedure
Purpose
Declaration
Remarks
See also
Example
var 8: string;
begin
while True do
begin
Readln(S) ;
if S =
then Break;
Writeln(S);
II
end;
end.
ChDir procedure
Purpose
Declaration
Remarks
System
15
ChOir procedure
GetDir, MkDir, RmDir. SetCurDir performs the same function, but it takes
a null-terminated string as an argument rather than a Pascal-style string.
Example
begin
{$I-}
{ Get directory n~me from command line }
ChDir(ParamStr(l));
,
if IOResult <> 0 then
Writeln(/Cannot find directory/);
end.
CheckBreak variable
Purpose
Declaration
Crt
Remarks
See also
CheckEOF variable
Purpose
Declaration
Remarks
Crt
CheckSnow variable
Purpose
Declaration
16
Crt
Programmer's Reference
CheckSnow variable
Remarks
Restrictions
See also
Chr function
Purpose
Declaration
System
Returns a character with a specified ordinal number.
function Chr (X: Byte): Chari
Remarks
Returns the character with the ordinal value (ASCII value) of the bytetype expression, X.
See also
Ord
Example
var I: Integer i
begin
for I := 32 to 255 do Write(Chr(I))i
end.
Circle procedure
Purpose
Declaration
Remarks
Restrictions
See also
Graph
Draws a circle in the current color set by SetColor. Each graphics driver
contains an aspect ratio used by Circle, Arc, and PieS lice.
Must be in graphics mode.
17
Circle procedure
Example
uses Graph;
var
Gd, Gm: Integer;
Radius: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
for Radius := 1 to 5 do
Circle(100, 100, Radius * 10);
Readlni
CloseGraph;
end.
ClearDevice procedure
Purpose
Declaration
Remarks
Restrictions
18
Graph
ClearDevice moves the current pointer to (0,0), clears the screen using th~
background color set by SetBkColor, and prepares it for output.
Must be in graphics mode.
See also
Example
Programmer's Reference
ClearViewPort procedure
ClearViewPort procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Sets the fill color to the background color (Palette[O]) and moves the
current pointer to (0, 0).
Must be in graphics mode.
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
Clipping constants
Purpose
Remarks
See also
Graph
Value
ClipOn
ClipOfJ
False
True
Set ViewPort
19
Close procedure
System
Close procedure
Purpose
Declaration
Remarks
F is a file variable of any file type previously opened with Reset, Rewrite,
or Append. The external file associated with F is completely updated and
then closed, freeing its DOS file handle for reuse.
With {$I-}, IOResult returns a if the operation was successful; otherwise, it
returns a nonzero error code.
See also
Example
var F: file;
begin
Assign(F, '\AUTOEXEC.BAT');
Reset(F,l);
Writeln('File size = " FileSize(F));
Close(F);
end.
CloseGraph procedure
Purpose
Declaration
Remarks
Restrictions
{ Open file }
{ Close file }
Graph
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
20
Programmer's Reference
CloseGraph procedure
Readlni
CloseGraphi
end.
Crt
ClrEol procedure
Purpose
Declaration
Remarks
Clears all characters from the cursor position to the end of the line
without moving the cursor.
procedure ClrEol i
All character positions are set to blanks with the currently defined text
attributes. Thus, if TextBaekground is not black, the current cursor position
to the right edge becomes the background color.
See also
ClrSer, Window
Example
uses Crt i
begin
TextBackground(LightGray)
ClrEoli
end.
ClrScr procedure
Purpose
Declaration
Remarks
Crt
Clears the active window and places the cursor in the upper left corner.
procedure ClrScr i
Sets all character positions to blanks with the currently defined text
attributes. Thus, if TextBaekground is not black, the entire screen becomes
the background color. This also applies to characters cleared by ClrEol,
InsLine, and DelLine, and to empty lines created by scrolling.
21
I!IIII
ClrScr procedure
See also
ClrEol, Window
Example
uses Crt;
begin
TextBackground(LightGray);
ClrScr;
end.
Color constants
Purpose
Remarks
Graph
Black
Blue
Green
Cyan
Red
AJagenta
Brown
LightGray
DarkGray
LightBlue
LightGreen
LightCyan
LightRed
LightAJagenta
Yellow
White
See also
Value
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
22
Graph
Purpose
Constants that can be used with SetRGBPalette to select the standard EGA
colors on an IBM 8514 graphics adapter.
Remarks
Programmer's Reference
Constant
EGABlack
EGABlue
EGAGreen
EGACyan
EGARed
EGAMagenta
EGABrown
EGALightGray
EGADarkGray
EGALightBlue
EGALight Green
EGALightCyan
EGALightRed
EGALightMagenta
EGAYellow
EGA White
See also
o (dark colors)
1
2
3
4
20
7
56 (light colors)
57
58
59
60
61
62
63
SetRGBPalette
Concat function
Purpose
Declaration
Remarks
Value
System
l: String): String;
See also
Example
var S: String;
begin
S := Concat('ABC', 'DEF');
end.
Continue procedure
Purpose
Declaration
{ , ABCDEF' }
System
23
Continue procedure
Remarks
See also
Example
var
I: Integer;
Name: string[79];
F: file;
begin
for I := 1 to ParamCount do
begin
Name := ParamStr(I);
Assign(F, Name);
{$I-}
Reset(F,l);
{$It}
if IOResult <> 0 then
begin
Writeln('File not found: ' Name);
Continue;
end;
Writeln(Name, ': " FileSize(F) , ' bytes');
Close(F) ;
end;
end.
Copy function
Purpose
Declaration
24
System
Returns a substring of a string.
function Copy (S: String; Index: Integer; Count: Integer): String;
Remarks
See also
Programmer's Reference
Copy function
Example
var S: string;
begin
S : =: 'ABCDEF';
{ 'BCD' }
S := Copy(S, 2, 3);
end.
Cos function
Purpose
Declaration
System
Returns the cosine of the argument.
function Cos (X: Real): Real;
Remarks
See also
ArcTan, Sin
Example
var R: Real;
begin
R := Cos(Pi);
end.
CreateDir procedure
Purpose
Declaration
WinDos
Remarks
See also
Crt
Remarks BW40, C040, BW80, and C080 represent the four color text modes
25
Constant
BW40
BWBO
Mono
C040
COBO
FontBxB
C40
CBO
See also
Value
o
2
7
1
3
256
C040
C080
Description
40x25 B /W on color adapter
80x25 B /W on color adapter
80x25 B/W on monochrome adapter
40x25 color on color adapter
80x25 color on color adapter
For EGA/VGA 43 and 50 line
For Turbo Pascal 3.0 compatibility
For Turbo Pascal3.0 compatibility
TextMode
CSeg function
Purpose
Declaration
System
Returns the current value of the CS register.
function CSeg: Word;
Remarks
The result of type Word is the segment address of the code segment within
which CSeg was called.
See also
DSeg, SSeg
.DateTime type
Purpose
Declaration
26
Dos
Remarks
Valid ranges are Year 1980 .. 2099, Month 1..12, Day 1..31, Hour 0.. 23, Min
0..59, and Sec 0..59.
See also
Programmer's Reference
Dec procedure
Dec procedure
Purpose
Declaration
Remarks
System
Decrements a variable.
procedure Dec (var X [ ; N: Longint 1 );
Example
var
IntVar: Integer;
LongintVar: Longint;
begin
Dec (IntVar) ;
Dec (LongintVar, 5);
{ IntVar := IntVar - 1
{ LongintVar := LongintVar - 5
end.
Delay procedure
Purpose
Declaration
Remarks
Crt
Delete procedure
Purpose
Declaration
Remarks
System
27
II
Delete procedure
specifies more characters than remain starting at the Indexth position, the
remainder of the string is deleted.
See also
DelUne procedure
Purpose
Declaration
Remarks
Crt
The line containing the cursor is deleted, and all lines below are moved
one line up (using the BIOS scroll routine). A new line is added at the
bottom.
All charader positions .are set to blanks with the currently defined text
attributes. Thus, if TextBackground is not black, the new line becomes the
background color.
Example
DelLine is window-relative. The following example will delete the first line
in the window, which is the tenth line on the screen.
Window(l, 10, 60, 20) i
DelLinei
See also
InsLine, Window
DetectGraph procedure
Purpose
Declaration
Remarks
Graph
Checks the hardware and determines which graphics driver and mode to
use.
procedure DetectGraph (var GraphDriver, GraphMode: Integer) i
Returns the detected driver and mode value that can be passed to
InitGraph, which will then load the correct driver. If no graphics hardware
was detected, the GraphDriver parameter and GraphResult returns a value
of grNotDetected. See page 33 for a list of driver and mode constants.
Unless instructed otherwise, In it Graph calls DetectGraph, finds and loads
the correct driver, and initializes the graphics system. The only reason to
call DetectGraph directly is to override the driver that DetectGraph recommends. The example that follows identifies the system as a 64K or 256K
EGA, and loads the CGA driver instead. When you pass InitGraph a
GraphDriver other than Detect/you must also pass in a valid GraphMode for
the driver requested.
.
28
Programmer's Reference
DetectGraph procedure
Restrictions
You should not use DetectGraph (or Detect with InitGraph) with the IBM
8514 unless you want the emulated VGA mode.
See also
Example
uses Graph;
var GraphDriver GraphMode: Integer;
begin
DetectGraph(GraphDriver GraphMode);
if (GraphDriver = EGA) or
(GraphDriver = EGA64) then
begin
GraphDriver := CGA;
GraphMode := CGAHi;
end;
InitGraph(GraphDriver GraphMode II);
if GraphResult <> grOk then
Halt (1);
Line(OI 0 GetMaxX I GetMaxY);
Readln;
CloseGraph;
end.
DirectVideo variable
Purpose
Declaration
Remarks
Crt
Enables and disables direct memory access for Write and Writeln
statements that output to the screen.
var DirectVideo: .Boolean;
When DirectVideo is True, Writes and Writelns to files associated with the
CRT will store characters directly in video memory instead of calling the
BIOS to display them. When DirectVideo is False, all characters are written
through BIOS calls, which is a significantly slower process.
DirectVideo always defaults to True. If, for some reason, you want
characters displayed through BIOS calls, set DirectVideo to False at the
beginning of your program and after each call to TextMode.
See also
CheckS now
29
DiskFree function
DiskFree function
Purpose
Declaration
Dos, WinDos
Remarks
See also
DiskSize, GetDir
Example
uses Dos i
begin
Writeln(DiskFree(O) div 1024, , Kbytes free')i
end.
{ or WinDos }
DiskSize function
Purpose
Declaration
Dos, WinDos
Remarks
See also
DiskFree GetDir
Example
uses Dos i
begin
Writeln(DiskSize(O) div 1024, , Kbytes capacity') i
end.
Dispose procedure
Purpose
Declaration
Remarks
{ or WinDos }
System
30
Programmer's Reference
Dispose procedure
Example
DosError variable.
Purpose
Declaration
Remarks
Dos, WinDos
The values stored in DosError are DOS error codes. A value of 0 indicates
no error; other possible error codes include the following:
DOS error code
2
3
5
6
8
10
11
18
Meaning
31
DosExitCode fun~tion
DosExitCode function
Purpose
Declaration
Remarks
Dos
The low byte is the code sent by the terminating process. The high byte is
set to
0 for normal termination
1 if terminated by Ctr/+C
.2 if terminated due to a device error
3 if terminated by the Keep procedure
See also
Exec, Keep
DosVersionfunction
Purpose
Declaration
Dos, WinDos
Remarks
Dos Version returns the DOS version number. The low byte of the result is
the major version number, and the high byte is the minor version number.
For example, DOS 3.20 returns 3 in the low byte, and 20 in the high byte.
Example
uses Dos;
var Ver: Word;
begin
Ver := DosVersion;
Writeln('This is DOS version', Lo(Ver),
end.
See also
{ or WinDos }
Hi (Ver));
Hi, Lo
DrawPoly procedure
Purpose
Declaration
Remarks
32
Graph
Draws the outline of a polygon using the current line style and color.
procedure DrawPoly (NumPoints: Word; var PolyPoints);
Programmer's Reference
DrawPoly procedure
DrawPoly uses the current line style and color. Use SetWriteMode to
determine whether the polygon is copied to or XORed to the screen.
Note that in order to draw a closed figure with N vertices, you must pass
N + 1 coordinates to DrawPoly, where
PolyPoints[N + 1] = PolyPoints[l]
In order to draw a triangle, for example, four coordinates must be passed
to DrawPoly.
Restrictions
See also
Example
uses Graph;
const
Triangle: array [1. .4] of PointType = ((X: 50; Y: 100), (X: 100; Y: 100),
(X: 150; Y: 150), (X: 50; Y: 100));
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
DrawPoly(SizeOf(Triangle) div SizeOf(PointType), Triangle);
Readln;
CloseGraph;
end.
Graph
Purpose
Used with routines that call graphics drivers and color palettes.
Remarks
Table 1.1
Graph unit driver
constants
Driver Constant
Detect
CGA
MCGA
EGA
EGA64
EGAMono
IBM8514
HercMono
{ 4 }
Value
0
1
2
3
4
5
6
7
Meaning
Requests autodetection
CGAmode
MCGAmode
EGA mode
EGA64 mode
EGAMono mode
IBM8514 mode
HercMono mode
33
ATT400
VGA
PC3270
CurrentDriver
8
9
10
-128
ATT400mode
VGAmode
PC3270mode
Passed to GetModeRange
Column
Value
Palette
Colors
Pages
ATT400CO
ATT400Cl
ATT400C2
ATT400C3
ATT400Med
ATT400Hi
0
1
2
3
4
5
320x200
320x200
320x200
320x200
640x200
640x400
0
1
2
3
1
1
1
1
CGACO
CGACl
CGAC2
CGAC3
CGAHi
0
1
2
3
4
320x200
320x200
320x200
320x200
640x200
0
1
2
3
1
1
1
1
EGALo
EGAHi
EGA64Lo
EGA64Hi
EGAMonoHi
0
1
0
1
3
640x200
640x350
640x200
640x350
640x350
16 color
16 color
16 color
4 color
64Kon catd,
256K on card
4
2
1
1
1
2
HercMonoHi
720x348
IBM8514Lo
IBM8514Hi
0
1
640x480
1024x768
MCGACO
MCGACl
MCGAC2
MCGAC3
MCGAMed
MCGAHi
0
1
2
3
4
5
320x200
320x200
320x200
320x200
640x200
640x480
PC3270Hi
720x350
VGALo
VGAMed
VGAHi
0
1
2
640x200
640x350
640x480
See also
34
x Row
256 colors
256 colors
0
1
2
3
1
1
1
1
16 color
16 color
16 color
4
2
1
Programmer's Reference
DSeg function
DSeg function
Purpose
Declaration
System
Returns the current value of the DS register.
function DSeg: Word;
Remarks
The result of type Word is the segment address of the data segment.
See also
CSeg, SSeg
Ellipse procedure
Purpose
Declaration
Remarks
Graph
Draws an elliptical arc from start angle to end angle, using (X, Y) as the
center point.
procedure Ellipse(X, Y: Integer; StAngle, EndAngle: Word;
YRadius, YRadius: Word);
Draws an elliptical arc in the current color using (X, Y) as a center point,
and XRadius and YRadius as the horizontal and vertical axes travelling
from StAngle to EndAngle.
A start angle of 0 and an end angle of 360 draws a complete oval. The
angles for Are, Ellipse, and PieS lice are counterclockwise with 0 degrees at
3 o'clock, 90 degrees at 12 0' clock, and so on. Information about the last
call to Ellipse can be retrieved by GetArcCoords.
Restrictions
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
35
EnvCount function
EnvCount function
Purpose
Declaration
Remarks
Dos
For more information about the DOS environment, see your DOS
manuals.
See also
EnvStr, GetEnv
Example
uses Dos i
var I: Integeri
begin
for I := 1 to EnvCount do
Writeln(EnvStr(I)) i
end.
EnvStr function
Purpose
Declaration
Remarks
Dos
EnvStr returns a specified string from the DOS environment. The string
EnvStr returns is of the form VAR= VALUE. The index of the first string is
one. If Index is less than one or greater than EnvCount, EnvStr returns an
empty string.
For more information about the DOS environment, see your DOS
manuals.
See also
EnvCount, GetEnv
36
System
Programmer's Reference
beyond the last character of the file or if the file contains no components;
otherwise, Eof(F) returns False.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
See also
Eoln,SeekEof
Example
var
F: Text;
Ch: Char;
begin
{ Get file to read from command line }
Assign(F, ParamStr(l));
Reset(F);
while not Eof(F) do
begin
Read (F, Ch);
Write (Ch) ;
end;
end.
System
F is a file variable. Eof(F) returns True if the current file position is beyond
the last component of the file or if the file contains no components;
otherwise, Eof(F) returns False.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Eoln function
Purpose
Declaration
Remarks
System
Returns the end-of-line status of a text file.
function Eoln [(var F: Text) 1: Boolean;
37
Eoln function
Eof, SeekEoln
Erase procedure
Purpose
Declaration
Remarks
System
F is a file variable of any file type. The external file associated with F is
erased.
With {$I.;.}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Restri~tions
38
See also
Rename
Example
var
F: file;
Ch: Char;
begin
{ Get file to delete from command line }
Assign(F, ParamStr(l));
{$I-}
Reset(F);
{$It}
if IOResult <> 0 then
Writeln('Cannot find' ParamStr(l))
else
begin
Close (F) ;
Write('Erase " ParamStr(l) , '? ');
Readln (Ch) ;
if UpCase(Ch) = 'Y' then
Erase (F) ;
end;
end.
Programmer's Reference
ErrorAddr variable
ErrorAddr variable
Purpose
Declaration
Remarks
System
the address of the statement in error. For additional information, see "Exit
procedures" in Chapter 20 in the Language Guide.
See also
ExitCode, ExitProc
Exclude procedure
Purpose
Declaration
Remarks
System
corresponds to
S:=S-[1]
Include
Dos
Exec procedure
Purpose
Declaration
Remarks
The program name is given by the Path parameter, and the command line
is given by c,mdLine. To execute a DOS internal command, run '
COMMAND. COM; for instance,
Exec('\COMMAND.COM', , IC D1R *.PAS');
39
II
Exec procedure
call toExec. Swap Vectors swaps the contents of the SavelntXX pointers in
the System unit with the current contents of the interrupt vectors. This
ensures that the Exec'd process does not use any interrupt handlers
installed by the current process, and vice versa.
Exec does not change the memory allocation state before executing the
program. Therefore, when compiling a program that uses Exec, be sure to
reduce the maximum heap size using a $M compiler directive; otherwise,
there won't be enough memory (DosError = 8).
See also
Example
{$M $4000,O,O}
{ 16K stack, no heap required or reserved }
uses Dos;
var ProgramName, CmdLine: String;
begin
Write('Program to Exec (include full path): ');
Readln(ProgramName) ;
write('Command line to pass to " ProgramName, ': ');
Readln(CmdLine);
writeln('About to Exec ... ');
SwapVectors;
Exec (ProgramName, CmdLine);
SwapVectors;
Writeln(' ... back from Exec');
{ Error? }
if DosError <> 0 then
Writeln('Dos error #', DosError)
else
Writeln('Exec successful. Child process exit code =' DosExitCode);
end.
Exit procedure
Purpose
Declaration
Remarks
40
System
Programmer's Reference
Exit procedure
See also
Halt
Example
procedure WasteTime;
begin
repeat
if KeyPressed then Exit;
Write('Xx');
until False;
end;
II
begin
WasteTime;
end.
ExitCode variable
Purpose
Declaration
System
Remarks
See also
ExitProc variable
Purpose
Declaration
System
Remarks
See also
41
Expfunction
Exp function
Purpose
Declaration
System
Returns the exponential of the argument.
function Exp (X: Real): Reali
Remarks
See also
Ln
WinDos
See also
Value
fcExtension
fcFileName
fcDirectory
fcWildcards
$0001
$0002
$0004
$0008
FileSplit
Dos
FExpand function
Purpose
Declaration
Remarks
Expands the filename in Path into a fully qualified file name. The
resulting name is converted to uppercase and consists of a drive letter, a
colon, a root relative directory path, and a file name. Embedded '.' and ' .. '
directory references are removed.
The PathStr type is defined in the Dos unit as string[79].
Assuming that the current drive and directory is C: \ SOURCE \ PAS, the
following FExpand calls would produce these values:
FExpand('test.pas')
FExpand(' .. \*.TPU')
FExpand('c:\bin\turbo.exe')
42
'C:\SOURCE\PAS\TEST.PAS'
'C:\SOURCE\*.TPU'
'C:\BIN\TURBO.EXE'
Programmer's Reference
FExpand function
FSplit can separate the result of FExpand into a drivel directory string, a
file-name string, and an extension string.
See also
Dos, WinDos
Remarks
These are the file attribute constants defined in the Dos and WinDos units.
Dos Constant
WinDos Constant
Value
ReadOnly
Hidden
SysFile
VolumeID
Directory
Archive
AnyFile
faReadOnly
faHidden
faSysFile
faVolumeID
faDirectory
faArchive
faAnyFile
$01
$02
$04
$08
$10
$20
$3F
S)i
{ Dos }
or
FindFirst('*.*', faReadOnly + faDirectory, S) i
{ WinDos }
will locate all normal files as well as read-only files and subdirectories in
the current directory. The AnyFile (orfaAnyFile) constant is simply the
sum of all attributes.
See also
WinDos
Contain the maximum file name component string lengths used by the
functions FileSearch and FileExpand.
The following file name length constants are defined:
43
Constant
fsPathName
fsDirectory
fsFileName
fsExtension
See also
Value
79
67
8
FileSearch, FileSplit
WinDos
FileExpand function
Purpose
Declaration
Remarks
Expands the file name in Name into a fully qualified file name. The
resulting name is converted to uppercase and consists of a drive letter, a
colon, a root relative directory path, and a file name. Embedded '.' and ' .. '
directory references are removed, and all name and extension components
are truncated to 8 and 3 characters respectively. The returned value is
Dest. Dest and Name can refer to the same location.
Assuming that the current drive and directory is C: \SOURCE\PAS, the
following FileExpand calls would produce these values:
'test.pas') = 'C: \SOURCE\PAS\TEST. PAS'
FileExpand(S, ' .. \*.TPW') = 'C:\SOURCE\*.TPW'
FileExpand(S, 'c:\bin\turbo.exe') = 'C:\BIN\TURBO.EXE'
FileExp~nd(S,
The FileSplit function can be used to split the result of FileExpand into a
drive / directory string, a file-name string, and an extension string.
See also
String types are used by various procedures and functions in the Dos unit.
Remarks
See also
44
Dos
{ Command-line
{ Full file path
{ Drive and directory
{ File-name
{ File-extension
string}
string }
string }
string }
string }
FExpand, FSplit
Programmer's Reference
FileMode variable
Purpose
Declaration
Remarks
System
Determines the access code to pass to DOS when typed and untyped files
are opened using the Reset procedure.
var FileMode: Byte;
The range of valid FileMode values depends on the version of DOS in use.
For all versions, however, the following modes are defined:
o
1
2
Read only
Write only
Read/Write
The default value, 2, allows both reading and writing. Assigning another
value to FileModecauses all subsequent Resets to use that mode. New files
using Rewrite are always opened in read/write mode (that is,
FileMode = 2).
DOS version 3.x and higher defines additional modes, which are
primarily concerned with file-sharing on networks. For more details, see
your DOS programmer's reference manual.
See also
Rewrite
FilePos function
Purpose
Declaration
Remarks
System
F is a file variable. If the current file position is at the beginning of the file,
FilePos(F) returns O. If the current file position is at the end of the file-that
is, if Eof(F) is True-FilePos(F) is equal to FileSize(F).
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Restrictions
See also
FileSize, Seek
45
FileRec type
FileRec type
Dos
Purpose
Record definition used internally by Turbo Pascal and also declared in the
Dos unit.
Declaration
type
FileRec = record
Handle: Word;
Mode: Word;
RecSize: Word;
Private: array[1 .. 26] of Byte;
UserData: array[l .. 16] of Byte;
Name: array[O .. 79] of Char;
end;
Remarks
FileRec defines the internal data format of both typed and untyped files.
See also
.TextRec
FileSearch function
Purpose
Declaration
Remarks
WinDos
Searches for the file given by Name in the list of directories given by List.
The directories in List must be separated by semicolons, just like the
directories specified in a PATH command in DOS. The search alw~ys
starts with the current directory of the current drive. If the file is found,
FileSearch stores a concatenation of the directory path and the file name in
Dest. Otherwise, FileSearch stores an empty string in Dest. ~e returned
value is Dest. Dest and Name must not refer to the same location.
The maximum length of the result is defined by the fsPathName constant,
which is 79.
To search the PATH used by DOS to locate executable files, call
GetEnv Var('P ATH') and pass the result to FileSearch as the List parameter.
The result of FileSearch can be passed to FileExpand to convert it into a
fully qualified file name; that is, an uppercase file name that includes both
a drive letter and a root-relative directory path. In addition, you can use
FileSplit to split the file name into a drivel directory string, a file-name
string, and an extension string ..
46
Programmer's Reference
FileSearch function
See also
Example
uses WinDos;
var
8: array[O .. fsPathName] of Char;
begin
File8earch(8, , TURBO. EXE' , GetEnvVar('PATH'));
if 8[0] = #0 then
Writeln('TURBO.EXE not found')
else
Writeln('Found as " FileExpand(S, 8));
end.
FileSize function
Purpose
Declaration
Remarks
II
System
Restrictions
See also
FilePos
Example
FileSplit function
Purpose
Declaration
Remarks
WinDos
Splits the file name specified by Path into its three components. Dir is set
to the drive and directory path with any leading and trailing backslashes,
Name is set to the file name, and Ext is set to ~he extension with a
47
FileSplit function
Example
Graph
48
Purpose
Remarks
Value
Description
EmptyFill
SolidFill
LineFill
LtSlashFill
SlashFill
BkSlashFill
LtBkSlashFill
1
2
3
4
5
6
Programmer's Reference
HatchFill
XHatchFill
InterleaveFill
WideDotFill
CloseDotFill
UserFill
See also
8
9
10
11
12
System
FiliChar procedure
Purpose
Declaration
Remarks
See also
Example
Move
var
s:
string [ 80] ;
begin
end.
FiliEilipse procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Draws a filled ellipse using (X, Y) as a center point, and XRadius and
YRadius as the horizontal and vertical axes. The ellipse is filled with the
current fill color and fill style, and is bordered with the current color.
Must be in graphics mode.
49
FiliEllipse procedure
See also
Example
uses Graph;
const R = 30;
var
Driver, Mode: Integer;
Xasp, Yasp: Word;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult < 0 then
Halt (1);
{ Draw ellipse }
FillEllipse(GetMaxX div 2, GetMaxY div 2, 50, 50);
GetAspectRatio(Xasp, Yasp);
{ Circular ellipse }
FillEllipse(R, R, R, R * Longint(Xasp) div Yasp);
Readln;
CloseGraphi
end.
FiliPatternType type
Purpose
Declaration
See also
Graph
FiliPoly procedure
Purpose
Declaration
Remarks
Graph
50
Programmer's Reference
FiliPoly procedure
See also
Example
uses Graph;
const
Triangle: array[1 .. 3J of PointType = ((X:
(X: 100; Y: 100), (X: 150; Y: 150));
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
II
50; Y: 100),
Halt (1);
FiliSettingsType type
Purpose
Declaration
See also
The record that defines the pattern and color used to fill an area.
type
FillSettingsType = record
Pattern: Word;
Color: Word;
end;
GetFillSettings
FindFirst procedure
Purpose
Declaration
Remarks
Graph
Dos, WinDos
Searches the specified (or current) directory for the first entry matching
the specified file name and set of attributes.
procedure FindFirst(Path: String; Attr: Word; var S: SearchRec);
{ Dos
{ WinDos }
Path is the directory mask (for example, * . *). The Attr parameter specifies
the special files to include (in addition to all normal files). See page 43 for
a list of Dos and WinDos file attribute constants.
51
FindFirst procedure
Example
uses Dos;
var DirInfo: SearchRec;
begin
FindFirst('*.PAS', Archive, DirInfo);
while DosError = 0 do
begin
Writeln(DirInfo.Name);
FindNext(DirInfo);
end;
end.
FindNext procedure
Purpose
Declaration
}
}
}
}
Dos, WinDos
Returns the next entry that matches the name and attributes specified in a
previous call to FindFirst.
procedure FindNext (var S: SearchRec);
procedure FindNext(var S: TSearchRec)
52
{ or WinDos
{ or TSearchRec
{ or faArchive
{ Same as DIR *.PAS
{ Dos
{ WinDos
Remarks
The search record must be the same search record passed to FindFirst.
Errors are reported in DosError; the only possible error code is 18 (No
more files).
See also
Example
Programmer's Reference
Flag constants
Flag constants
Purpose
Dos, WinDos
Used to test individual flag bits in the Flags register after a call to Intr or
MsDos.
Remarks
Constants
Value
FCarry
FParity
FAuxiliary
FZero
FSign
FOverflow
$0001
$0004
$0010
$0040
$0080
$0800
are True respectively if the Carry flag is set and if the Zero flag is clear.
See also
Intr, MsDos
FloodFili procedure
Purpose
Declaration
Remarks
Graph
grNoFloodMem.
Note that FloodFill stops after two blank lines have been output. This can
occur with a sparse fill pattern and a small polygon. In the following
program, the rectangle is not completely filled:
program StopFill;
uses Graph;
53
FloodFili procedure
begin
Driver := Detecti
InitGraph(Driver, Mode, 'c:\bgi') i
if GraphResult <> grOk then
Halt(l) i
SetFillStyle(LtSlashFill, GetMaxColor)i
Rectangle (0, 0, 8, 20) i
FloodFill(l, 1, GetMaxColor)i
Readlni .
CloseGraphi
end.
In this case, using a denser fill pattern like SlashFill will completely fill the
figure.
Restrictions
See also
Example
uses Graphi
var Gd, Gm: Integeri
begin
Gd := Detect;
InitGraph(Gd, Gm, ")i
if GraphResult <> grOk then
Halt(l)i
SetColor(GetMaxColor)i
Circle(50, 50, 20) i
FloodFill(50, 50, GetMaxColor)
Readlni
CloseGraphi
end.
Flush procedure
Purpose
Declaration
Remarks
System
54
Programmer's Reference
fmXXXX constants
Dos, WinDos
fmXXXX constants
Purpose
Defines the allowable values for the Mode field of a TextRec and TFileRec
text file record.
Remarks
The Mode fields of Turbo Pascal's file variables contain one of the values
specified here:
See also
Constant
Value
fmClosed
fmlnput
fmOutput
fmlnOut
$D7BO
$D7Bl
$D7B2
$D7B3
TextRec, TFileRec
Graph
See also
Value
DefaultFont
TriplexFont
SmallFont
SansSerifFont
GothicFont
HorizDir
VertDir
a (left to right)
UserCharSize
1 ("stroked" fonts)
2
3 '
4
1 (bottom to top)
Frac function
Purpose
Declaration
II
System
Returns the fractional part of the argument.
function Frac (X: Real): Real i
55
Frac function
Remarks
See also
Int
Example
var R: Real;
begin
R
R
:=
:=
Frac(123.456);
Frac(-123.456);
{ 0.456 }
{ -0.456 }
end.
FreeList variable
Purpose
Declaration
Remarks
The FreeList variable points to the first free block in the heap. This block
contains a pointer to the next free block, which contains a pointer to the
next free block, and so forth. The last free block contains a pointer to the
'top of the heap. If there are no free blocks on the free list, FreeList will be
equal to HeapPtr. See Chapter 12, "Standard procedures and functions,"
in the Language Guide for more information.
See also
FreeMem procedure
Purpose
Declaration
56
System
System
Remarks
See/also
Programmer's Reference
FSearch function
FSearch function
Purpose
Declaration
Remarks
Dos
Searches for the file given by Path in the list of directories given by DirList.
The directories in DirList must be separated by semicolons, just like the
directories specified in a PATH command in DOS. The search always
starts with the current directory of the current drive. The returned value is
a concatenation of one of the directory paths and the file name, or an
empty string if the file could not be located.
To search the PATH,used by DOS to locate executable files, call
GetEnv('PATH') and pass the result to FSearch as the DirList parameter.
The result of FSearch can be passed to FExpand to convert it into a fully
qualified file name, that is, an uppercase file name that includes both a
drive letter and a root-relative directory path. In addition, you can use
FSplit to split the file name into a drivel directory string, a file-name
string, and an extension string.
See also
Example
uses Dos i
var S: PathStri
begin
S := FSearch('TURBO.EXE', GetEnv('PATH'))i
if S = " then
Writeln( 'TURBO.EXE not found')
else
Wri teln ( , Found as " FExpand (S)) i
end.
FSplit procedure
Purpose
Declaration
Remarks
Dos
Splits the file name specified by Path into its three components. Dir is set
to the drive and directory path with any leading and trailing backslashes,
Name is set to the file name, and Ext is set to the extension with a
57
II
FSpiit procedure
FSplit never adds or removes characters when it splits the file name, and
the concatenation of the resulting Dir, Name, and Ext will always equal the
specified Path.
See page 44 for a list of File-handling string types.
See also
Example
uses
var
P:
D:
N:
E:
Dos;
PathStr;
DirStr;
NameStr;
ExtStr;
begin
="
then
N .- 'WORK';
if E = "
then
E . - '. PAS';
P
:=
D + N + E;
P);
GetArcCoords procedure
Purpose
Declaration
Remarks
Restrictions
58
Graph
Lets the user inquire about the coordinates of the last Arc command.
procedure GetArcCoords (var ArcCoords: ArcCoordsType);
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Programmer's Reference
GetArcCoords procedure
ArcCoords: ArcCoordsType;
begin
Gd := Detect;
InitGraph (Gd, Gm, ");
if GraphResuIt <> grOk then
HaItH) ;
Arc ( 100, 100, 0, 270, 30);
GetArcCoords(ArcCoords);
with ArcCoords do
Line (Xstart, Ystart, Xend, Yend);
ReadIn;
CIoseGraph;
end.
GetArgCount function
Purpose
Declaration
See also
Declaration
WinDos
GetArgStr function
Purpose
I
WinDos
Remarks
See also
GetAspectRatio procedure
Purpose
Declaration
Graph
Returns the effective resolution of the graphics screen from which the
aspect ratio (Xasp:Yasp) can be computed.
procedure GetAspectRatio (var Xasp, Yasp: Word);
59
GetAspectRatio procedure
Remarks
Restrictions
Each driver and graphics mode has an aspect ratio associated with it
(maximum Y resolution divided by maximum X resolution). This ratio
can be computed by making a call to GetAspectRatio and then dividing the
Xasp parameter by the Yasp parameter. This ratio is used to make circles,
arcs, and pie slices round.
Must be in graphics mode.
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Xasp, Yasp: Word;
XSideLength, YSideLength: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Ha1t(1);
GetAspectRatio(Xasp, Yasp);
XSideLength := 20;
{ Adjust Y length for aspect ratio
YSideLength := Round((Xasp I Yasp) * XSideLength);
{ Draw a "square" rectangle on the screen}
Rectangle (0, 0, XSideLength, YSideLength);
Readln;
CloseGraph;
end.
Graph
GetBkColor function
Purpose
Declaration
Remarks
Returns the index into the palette of the current background color.
function GetBkColor: Word;
60
Programmer's Reference
GetBkColor function
Example
Halt (1);
Randomize;
GetPalette(Pal);
if Pal.Size <> 1 then
begin
repeat
Color := Succ(GetBkColor);
if Color> Pal.Size-l then
Color := 0;
SetBkColor(Color);
LineTo(Random(GetMaxX) Random(GetMaxY));
until KeyPressed;
end
else
Line(O, 0, GetMaxX , GetMaxY);
Readln;
CloseGraph;
end.
GetCBreak procedure
Purpose
Declaration
Dos, WinDos
Remarks
See also
SetCBreak
61
GetColor function
GetColor function
Purpose
Declaration
Remarks
Restrictions
Graph
Returns the color value passed to the previous successful call to SetColor.
function GetColor: Word;
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Color: Word;
Pal: PaletteTypei
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
Randomize;
GetPalette (Pal) ;
repeat
Color := Succ(GetColor);
if Color> Pal.Size - 1 then
Color := 0;
SetColor(Color);
LineTo(Random(GetMaxX), Random(GetMaxY));
until KeYPressed;
CloseGraphi
end.
GetCurDir function
Purpose
Declaration
Remarks
WinDos
The string returned in Dir always starts with a drive letter, a colon, and a
backslash. Drive = 0 indicates the current drive, 1 indicates A, 2 indicates
B, and so on. The returned value is Dir. Errors are reported in DosError.
If the drive specified by Drive is invalid, Dir returns 'X:\', as if it were the
62
Programmer's Reference
GetCurDir function
GetDate procedure
Purpose
Declaration
Dos, WinDos
Remarks
Ranges of the values returned are Year 1980 .. 2099, Month 1..12, Day 1..31,
and DayOfWeek 0.. 6 (where 0 corresponds to Sunday).
See also
GetDefaultPalette function
Purpose
Declaration
Remarks
Restrictions
Graph
See also
Example
63
GetDefaultPalette function
for I := 0 to MyPal.Size - 1 do
begin
SetColor(I) ;
OutTextXY(10, I * 10, ' ... Press any key ... ');
end;
repeat
{ Change palette until a key is pressed }
with MyPal do
Colors[Randorn(Size)] := Randorn(Size + 1);
SetAllPalette(MyPal);
until KeyPressed;
SetAllPalette(OldPal);
{ Restore original palette}
ClearDevice;
OutTextXY(10, 10, 'Press <Return> ... ');
Readln;
CloseGraph;
end.
GetDir procedure
Purpose
Declaration
Remarks
System
See also
Graph:
GetDriverName function
Purpose
Declaration
Remarks
Restrictions
See also
64
Programmer's Reference
GetDriverNome function
Example
uses Graph;
var Driver, Mode: Integer;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult < 0 then
Halt (1);
GetEnv function
Purpose
Declaration
Remarks
I
Dos
For more information about the DOS environment, see your DOS
manuals.
See also
Example
EnvCount, EnvStr
{$M 8192,O,O}
uses Dos;
var Command: string[79];
begin
Write('Enter DOS command: ');
Readln (Command) ;
if Command <> " then
Command := ' IC ' + Command;
SwapVectors;
Exec(GetEnv('COMSPEC'), Command);
SwapVectors;
if Dos Error <> 0 then
Writeln('Could not execute COMMAND.COM');
end.
65
GetEnvVor function
GetEnvVar function
Purpos~
Declaration
WinDos
Remarks
Example
uses WinDos;
begin
Writeln{/The current PATH is
end.
GetEnvVar{/PATH/));
Dos, WinDos
GetFAttr procedure
Purpose
Declaration
Remarks
with the file attribute masks defined as constants in the Dos unit. See.
page 43 for a list of file attribute constants for Dos and WinDos units.
Errors are reported in DosError; possible error codes are
.3 (Invalid path)
.5 (File access denied)
Restrictions
F cannot be open.
See also
Example
uses Dos;
var
F: file;
Attr: Word;
begin
{ Get file name from command line }
Assign{F ParamStr{l));
GetFAttr{F Attr);
Writeln{ParamStr{l)) ;
{ or WinDos }
66
Programmer's Reference
GetFAttr procedure
GetFiliPattern procedure
Purpose
Declaration
Remarks
Restrictions
See also
Declaration
Remarks
Graph
GetFiliSettings procedure
Purpose
Graph
Returns the last fill pattern and color set by a previous call to SetFillPattern
or SetFillStyle.
procedure GetFillSettings (var Filllnfo: FillSettingsType);
The Pattern field reports the current fill pattern selected. The Color field
reports the current fill color selected. Both the fill pattern and color can be
changed by calling the SetFillStyle or SetFillPattern procedure. If Pattern is
67
GefFiliSettings procedure
equal to UserFill, use GetFillPattern to get the user-defined fill pattern that
is selected.
Restrictions
See also
Example
uses Graph;
var
Gd, Gm: Integer;
FillInfo: FillSettingsType;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
GetFillSettings(Filllnfo);
Bar (0, 0, 50, 50);
SetFillStyle(XHatchFill, GetMaxColor);
Bar (50, 0, 100, 50);
with FillInfo do
SetFillStyle(Pattern, Color);
Bar (100, 0, 150, 50);
Readln;
CloseGraph;
end.
GetFTime procedure
Purpose
Declaration
Remarks
Restrictions
See also
68
005 , WinDos
Programmer's Reference
GetGraphMode function
GetGraphMode function
Purpose
Declaration
Remarks
Graph
Constant
name
Value
Column
x row
Palette
Pages
CGA
CGACO
CGAC1
CGAC2
CGAC3
CGAHi
0
1
2
3
4
320x200
320x200
320x200
320x200
640x200
CO
C1
C2
C3
2 color
1
1
1
1
1
MCGA
MCGACO
MCGAC1
MCGAC2
MCGAC3
MCGAMed
MCGAHi
0
1
2
3
4
5
320x200
320x200
320x200
320x200
640x200
640x480
CO
C1
C2
C3
2 color
2 color
1
1
1
1
1
1
EGA
EGALo
EGAHi
0
1
640x200
640x350
16 color
16 color
4
2
EGA64
EGA64Lo
EGA64Hi
0
1
640x200
640x350
16 color
4 color
1
1
EGA-MONO
EGAMonoHi
EGAMonoHi
3
3
640x350
640x350
2 color
2 color
1*
2**
HERC
HercMonoHi
720x348
2 color
ATT400
ATT400CO
ATT400C1
ATT400C2
ATT400C3
ATT400Med
ATT400Hi
0
1
2
3
4
5
320x200
320x200
320x200
320x200
640x200
640x400
CO
C1
C2
C3
2 color
2 color
1
1
1
1
1
1
VGA
VGALo
VGAMed
VGAHi
0
L
2
640x200
640x350
640x480
16 color
16 color
16 color
2
2
1
69
GetGraphMode function
PC3270
PC3270Hi
720x350
2 color
IBM8514
IBM8514
IBM8514Lo
IBM8514Hi
0
0
640x480
1024x768
256 color
256 color
1
1
Restrictions
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Mode: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt(l);
Out Text ('<ENTER> to leave graphics:');
Readln;
RestoreCrtMode;
Writeln('Now in text mode');
Write('<ENTER> to enter graphics mode:');
Readln;
SetGraphMode(GetGraphMode) ;
OutTextXY(O, 0, 'Back in graphics mode');
OutTextXY(O, TextHeight('H'), '<ENTER> to quit:');
Readln;
CloseGraphi
end.
Graph
Getlmage procedure
Purpose
Declaration
Remarks
Xl, Yl, X2, and Y2 define a rectangular region on the screen. BitMap is an
untyped parameter that must be greater than or equal to 6 plus the
amount of area defined by the .region. The first two words of BitMap store
the width and height of the region. The third word is reserved.
The remaining part of BitMap is used to save the bit image itself. Use the
ImageSize function to determine the size requirements of BitMap.
70
Programmer's Reference
Getlmage procedure
Restrictions
Must be in graphics mode. The memory required to save the region must
be less than 64K.
See also
ImageSize, PutImage
Example
uses Graph;
var
Gd, Gm: Integer;
P: Pointer;
Size: Word;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
GetlntVec procedure
Purpose
Declaration
Dos , WinDos
Remarks
IntNo specifies the interrupt vector number (0 .. 255), and the address is
returned in Vector.
See also
SetIntVec
GetLineSettings procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Returns the current line style,line pattern, and line thickness as set by
SetLineStyle.
procedure GetLineSettings (var LineInfo: LineSettingsType);
71
GetLineSettings procedure
See also
Example
uses Graph;
var
Gd, Gm: Integer;
OldStyle: LineSettingsType;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
GetMaxColor function
Purpose
Declaration
Remarks
Restrictions
See also
Declaration
Remarks
72
Graph
Returns the highest color that can be passed to the SetColor procedure.
function GetMaxColor: Word;
SetColor
GetMaxMode function
Purpose
{ New style }
Graph
Returns the maximum mode number for the currently loaded driver.
function GetMaxMode: Word;
GetMaxMode lets you find out the maximum mode number for the current
driver, directly from the driver. (Formerly, GetModeRange was the only way
Programmer's Reference
GetMaxMode function
you could get this number; GetModeRange is still supported, but only for
the Borland drivers.)
The value returned by GetMaxMode is the maximum value that can be
passed to SetGraphMode. Every driver supports modes O.. GetMaxMode.
Restrictions
See also
GetModeRange, SetGraphMode
Example
uses Graph;
var
Driver, Mode: Integer;
I: Integer;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult < 0 then
I
{ Put in graphics mode }
Halt (1) ;
for I := 0 to GetMaxMode do
OutTextXY(10, 10 * Succ(I), GetModeName(I));
Readln;
CloseGraph;
end.
GetMaxX function
Purpose
Declaration
Remarks
Graph
Returns the maximum X value for the current graphics driver and mode.
On a eGA in 320x200 mode, for example, GetMaxX returns 319.
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
Chapter 7, Libraryreference
73
GetMaxX function
GetMaxY function
Purpose
Declaration
Remarks
Gr.aph
Returns the maximum y value for the current graphics driver and mode.
On a CGA in 320x200 mode, for example, GetMaxY returns 199.
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph (Gd, Gm, ");
if GraphResult <> grOk then
Halt(l);
Rectangle (0, 0, GetMaxX, GetMaxY);
Readln;
CloseGraph;
end.
GetMem procedure .
Purpose
Declaration
Remarks
System
74
Programmer's Reference
GetMem procedure
Restrictions
See also
The largest block that can be safely allocated on the heap at one time is
65,528 bytes (64K-$8).
GetModeName function
Purpose
Declaration
Remarks
Restrictions
The mode names are embedded in each driver. The return values (320x200
CGA PI, 640x200 CGA, and so on) are useful for building menus, display
status, and so forth.
Must be in graphics mode.
See also
Example
uses Graph;
var
Driver, Mode: Integer;
I: Integer;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult < 0 then
Halt (1);
for I := 0 to GetMaxMode do
OutTextXY(10, 10 * Succ(I), GetModeName(I));
Readln;
CloseGraph;
end.
GetModeRange procedure
Purpose
Declaration
Remarks
Graph
Graph
Returns the lowest and highest valid graphics mode for a given driver.
procedure GetModeRange (GraphDri ver: Integer; var LoMode, HiMode: Integer);
The output from the following program will be Lowest = 0 and Highest = 1:
uses Graph;
var Lowest, Highest: Integer;
begin
GetModeRange(EGA64, Lowest, Highest);
75
GetModeRange procedure
If the value of GraphDriver is invalid, the LoMode and HiMode are set to-1.
See also
GetPalette procedure
Purpose
Declaration
76
Graph
Remarks
Returns the current palette and its size in a variable of type PaletteType.
Restrictions
Must be in graphics mode, and can only be used with EGA,EGA 64, or
VGA (not the IBM 8514 or the VGA in 256-color mode).
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Color: Word;
Palette:. PaletteType;
begin,
Gd := Detect;
InitGraph{Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
GetPalette{Palette);
if Palette. Size <> 1 then
for Color := 0 to Pred{Palette.Size) do
begin
SetColor{Color);
Line{O, Color * 5, 100, Color * 5);
end
else
Line (0, 0, 100, 0);
Readln;
CloseGraph;
end.
Programmer's Reference
GetPaletteSize function
GetPaletteSize function
Purpose
Declaration
Remarks
Restrictions
See also
GetPaletteSize reports how many palette entries can be set for the current
graphics mode; for example, the EGA in color mode returns a value of 16.
Must be in graphics mode.
GetPixel function
Purpose
Declaration
Remarks
Restrictions
Graph
Graph
See also
Example
uses Graph;
var
Gd, Gm: Integer;
PixelColor: Word;
begin
Gd := Detect;
InitGraph(Gd, Gm, "):
if GraphResult <> grOk then
Halt (1);
77
GetTextSettings procedure
Graph
GetTextSettings procedure
Purpose
. Declaration
Remarks
Restrictions
Returns the current text font, direction, size, and justification as set by
SetTextStyle and SetTextJustify .
procedure GetTextSettings (var TextInfo: TextSettingsType);
See page 55 for the declaration of the Font control constants and page 196
for a declaration of the TextSettingsType record.
Must be in graphics mode.
See also
Example
uses Graph;
var
Gd, Gm: Integer;
OldStyle: TextSettingsType;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
GetTextSettings(OldStyle) ;
OutTextXY(O, 0, 'Old text style');
SetTextJustify(LeftText, CenterText);
SetTextStyle(TriplexFont, VertDir, 4);
. OutTextXY(GetMaxX div 2, GetMaxY div 2, 'New Style');
with OldStyle do
{ Restore old text style }
begin
SetTextJustify(Horiz, Vert);
SetTextStyle(Font, Direction, CharSize);
end;
OutTextXY(O, TextHeight('H'), 'Old style again');
Readln;
CloseGraph;
end.
Dos, WinDos
GetTime procedure
78
Purpose
Declaration
Programmer's Reference
GetTime procedure
Remarks
Ranges of the values returned are Hour 0.. 23, Minute 0..59, Second 0.. 59,
and Sec100 (hundredths of seconds) 0.. 99.
See also
GetVerify procedure
Purpose
Declaration
Dos, WinDos
Remarks
GetVerify returns the state of the verify flag in DOS~ When off (False), disk
writes are not verified. When on (True), all disk writes are verified to
ensure proper writing.
See also
Set Verify
GetViewSettings procedure
Purpose
Declaration
Remarks
Restrictions
Graph
See also
Example
uses Graph;
var
Gd, Gm: Integer;
ViewPort: ViewPortType;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
GetViewSettings(ViewPort);
with ViewPort do
begin
Rectangle (0, 0, X2 - Xl, Y2 - Y1);
if Clip then
OutText('Clipping is active.')
79
GetViewSettings procedure
else
Out Text ('No clipping today.');
end;
Readln;
CloseGraph;
end.
GetX function
Purpose
'Declaration
Remarks
Graph
Returns the X coordinate of the current position (CP).
function GetX: Integer;
Get~axY,
True);
var
Gd, Gm: Integer;
X, Y: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
80
Programmer's Reference
GetV function
GetV function
Purpose
Declaration
Remarks
Graph
Returns the Y coordinate of the current position (CP).
function GetY: Integer;
a,
var
Gd, Gm: Integer;
X, Y: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
GotoXV procedure
Purpose
Declaration
Crt
81
GotoXY procedure
Remarks
Moves the cursor to the position within the current window specified by
X and Y (X.is the column, Yis the row). The upper left corner is (I, 1).
This procedure is window-relative. The following example moves the
cursor to the upper left corner of the active window (absolute coordinates
(I, 10)):
Window(l, 10, 60, 20);
GotoXY(l, 1);
Restrictions
See also
If the coordinates are in any way invalid, the call to GataXY is ignored.
GraphDefaults procedure
Purpose
Declaration
Remarks
Graph
Homes the current pointer (CP) and resets the graphics system to the
default values for
Viewport
Restrictions
See also
Palette
Draw and background colors
Line style and line pattern
Fill style, fill color, and fill pattern
Active font, text style, text justification, and user Char size
InitGraph
GraphErrorMsg function
Purpose
Declaration
Remarks
82
Graph
Programmer's Reference
GraphErrorMsg function
See also
Example
uses Graph;
var
GraphDriver, GraphMode: Integer;
ErrorCode: Integer;
begin
GraphDriver := Detect;
InitGraph(GraphDriver, GraphMode, ");
ErrorCode := GraphResult;
if ErrorCode <> grOk then
begin
Writeln('Graphics error: ' GraphErrorMsg(ErrorCode));
Readln;
Halt (1);
end;
Line(O, 0, GetMaxX, GetMaxY);
Readln;
CloseGraph;
end.
GraphFreeMemPtr variable
Purpose
Declaration
Remarks
GraphGetMemPtr variable
Purpose
Declaration
Remarks
Graph
Graph
83
GraphResult function
Graph
GraphResultfunction
Purpose
Declaration
Remarks
Ear
Bar3D
ClearViewPort
CloseGraph
DetectGraph
DrawPoly
FillPoly
FloodFill
GetGraphMode
Imagesize
InitGraph
InstallUserDriver
InstallUserFont
PieS lice
RegisterBGldriver
RegisterBGIfont
setAllPalette
setFillPattern
setFillStyle
setGraphBufsize
setGraphMode
setLinestyle
setPalette
setTextJustify
setTextstyle
Note that GraphResult is reset to zero after i~ has been called (similar to
IOResult). Therefore, the user should store the value of GraphResult into a
temporary variable and then test it.
A string function, GraphErrorMsg, is provided to return a string that
corresponds with each error code.
See also
Example
ErrorCode: Integer;
GrDriver , GrMode: Integer;
begin
GrDriver := Detect;
InitGraph(GrDriver , GrMode , ");
ErrorCode := GraphResu1t;
if ErrorCode <> grOk then
begin
Write1n('Graphics error: ');
Write1n(GraphErrorMsg(ErrorCode)) ;
Write1n(IProgram aborted .. . ');
Halt (1) ;
end;
84
Programmer's Reference
GraphResult function
Graph
grXXXX constants
Purpose
Remarks
See also
Constant
Value
grOk
grNolnitGraph
gr Not Detected
grFileNotFound
grlnvalidDriver
grNoLoadMem
grNoScanMem
grNoFloodMem
grFontNotFound
grNoFontMem
grlnvalidMode
grError
-11
grIOerror
grlnvalidFont
grlnvalidFontNum
-12
-13
-14
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
Description
No error.
(BGI) graphics not installed (use InitGraph).
Graphics hardware not detected.
Device driver file not found.
Invalid device driver file.
Not enough memory to load driver.
Out of memory in scan fill.
Out of memory in flood fill.
Font file not found.
Not enough memory to load font.
Invalid graphics mode for selected driver.
Graphics error (generic error); there is no room in
the font table to register another font. (The font
table holds up to 10 fonts, and only 4 are
provided, so this error should not occur.)
Graphics 1/ a error.
Invalid font file; the font header isn't recognized.
Invalid font number; the font number in the font
header is not recognized.
GraphResult
Halt procedure
Purpose
Declaration
Remarks
System
85
Halt procedure
Exit, RunError
System
HeapEnd variable
Purpose
Declaration
,Remarks
See also
HeapEnd is initialized by the system unit when your program begins. See
Chapter 19, UMemory issues," in the Language Guide for more information.
HeapOrg, HeapPtr
HeapError variable
Purpose
Declaration
Remarks
System
See Chapter 19, "Memory issues," in the Language Guide for more
information about using heap error functions.
See also
GetMem, New
HeapOrg variable
Purpose
.Declaration
86
System
Remarks
HeapOrg contains the address of the bottom of the heap. See Chapter 19,
"Memory issues," in the Language Guide for more information.
See also
HeapEnd, HeapPtr
Programmer's Reference
HeapPtr variable
HeapPtr variable
Purpose
Declaration
System
Remarks
HeapPtr contains the address of the top of the heap, that is, the bottom of
free memory. Each time a dynamic variable is allocated on the heap, the
heap manager moves HeapPtr upward by the size of the variable. See
Chapter 19, "Memory issues," in the Language Guide for more information.
See also
HeapOrg, HeapEnd
Hi function
Purpose
Declaration
System
Returns the high-order byte of the argument.
function Hi (X): Byte;
Remarks
See also
La, Swap
Example
var B: Byte;
begin
B := Hi($1234);
end.
High function
Purpose
Declaration
Result type
Remarks
{ $12 }
System
Returns the highest value in the range of the argument.
function High (X) ;
87
High function
Low
Example
HighVideo procedure
Purpose
Declaration
Remarks
See also
Example
uses Crt;
begin
TextAttr := LightGray;
HighVideo;
end.
ImageSize function
Purpose
Declaration
Remarks
88
Crt
Graph
Xl, Yl, X2, and Y2 define a rectangular region on the screen. ImageSize
determines the number of bytes necessary for GetImage to save the
specified region of the screen. The image size includes space for several
words. The first stores the width of the region, and the second stores the
height. The next words store the attributes of the image itself. The last
word is reserved.
Programmer's Reference
ImageSize function
If the memory required to save the region is greater than or equal to 64K,
See also
GetImage, PutImage
Example
uses Graph;
var
Gd, Gm: Integer;
P: Pointer;
Size: Word;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
II
Halt (1);
Inc procedure
Purpose
Declaration
Remarks
System
Increments a variable ..
procedure Inc (var X [ ; N: Longint 1 );
Example
var
IntVar: Integer;
LongintVar: Longint;
89
Inc procedure
begin
Inc (IntVar) ;
Inc (LongintVar, 5);
end.
{ IntVar := IntVar + 1 }
{ LongintVar := LongintVar + 5 }
Include procedure
Purpose
Declaration
Remarks
System
corresponds to
8:=8+[I]
Exclude
Graph
InitGraph procedure
Purpose
Declaration
Remarks
Initializes the graphics system and puts the hardware into graphics mode.
procedure InitGraph(var GraphDriver: Integer; var GraphMode: Integer;
PathToDriver: 8tring);
PathToDriver specifies the directory path where the graphics drivers can
be found. If PathToDriver is null, the driver files must be in the current
directory.
90
Programmer's Reference
InitGraph procedure
See also
Example
Must be in graphics mode. If you use the Borland Graphics Interface (BGI)
on a Zenith Z-449 card, Turbo Pascal's autodetection code will always
select the 640x480 enhanced EGA mode. If this mode isn't compatible
with your monitor, select a different mode in the InitGraph call. Also,
Turbo Pascal cannot autodetect the IBM 8514 graphics card (the
autodetection logic recognizes it as VGA). Therefore, to use the IBM 8514
card, the GraphDriver variable must be assigned the value IBM8514 (which
is defined in the Graph unit) when InitGraph is called. You should not use
DetectGraph (or Detect with InitGraph) with the IBM 8514 unless you want
the emulated VGA mode.
var
grDriver: Integer;
grMode: Integer;
91
InitGraph procedure
ErrCode: Integer;
begin
grDriver := Detect;
InitGraph(grDriver, grMode, ");
ErrCode :~ GraphResult;
if ErrCode = grOk then
begin
Line(O, 0, GetMaxX, GetMaxY);
Readln;
CloseGraph;
end
else
Writeln('Graphics error:', GraphErrorMsg(ErrCode));
end.
{ Do graphics }
System
InOutRes variable
Purpose
.Declaration
Remarks
See also
10Result
Input variable
Purpose
Declaration
Remarks
System
Standard input file.
var Input: Text;
92
Programmer's Reference
Input variable
See Chapter 13, "Input and output," in the Language Guide for details
about I/O issues.
See also
Output
System
Insert procedure
Purpose
Declaration
Remarks
See also
Example
var S: string;
begin
S := 'Honest Lincoln';
Insert ( 'Abe " s, 8);
end.
InsLine procedure
Purpose
Declaration
Remarks
Crt
All lines below the inserted line are moved down one line, and the bottom
line scrolls off the screen (using the BIOS scroll routine).
All character positions are set to blanks with the currently defined text
attributes. Thus, if TextBackground is not black, the new line becomes the
background color.
Example
See also
DelLine, Window
93
II
InstaliUserDriver function
InstaliUserDriver function
Graph
Purpose
Declaration
Remarks
There are two ways to use this vendor-supplied driver. Let's assume you
have a new video card called the Spiffy Graphics Array (SGA) and that
the SGA manufacturer provided you with a BGl device driver (SGA.BGl).
The easiest way to use this driver is to install it by calling InstallUserDriver
and then passing the return value (the assigned driver number) directly to
InitGraph:
var Driver, Mode: Integer;
begin
Driver := InstallUserDriver('SGA', nil);
if Driver = grError then
{ Table full?
Halt (1);
Mode : = 0;
InitGraph(Driver, Mode, ");
end.
The nil value for the AutoDetectPtr parameter in the InstallUserDriver call
indicates there isn't an autodetect function for the SGA.
The other, more general way to use this driver is to link in an autodetect
function that will be called by InitGraph as part of its hardware-detection
logic. Presumably, the manufacturer of the SGA gave you an autodetect
function that looks something like this:
{$F+}
94
Programmer's Reference
InstaliUserDriver function
{ Returns -11 }
{ Return recommended default video mode }
DetectSGA's job is to look for the SGA hardware at run time. If an SGA
isn't detected, DetectSGA returns a value of -11 (grError); otherwise, the
return value is the default video mode for the SGA (usually the best mix
of color and resolution available on this hardware).
Note that this function takes no parameters, returns a signed, integer-type
value, and must be a far call. When you install the driver (by calling
InstallUserDriver), you pass the address of DetectSGA along with the
device driver's file name:
var Driver, Mode: Integer;
begin
Driver := InstallUserDriver('SGA', @DetectSGA);
if Driver = grError then
Ha1t(l) ;
Driver := Detect;
InitGraph(Driver, Mode, ");
{ Discard SGA driver #; trust autodetection }
{ Table full? }
end.
After you install the device driver file name and the SGA auto detect
function, you call InitGraph and let it go through its normal autodetection
process. Before InitGraph calls its built-in autodetection function
(DetectGraph), it first calls DetectSGA. If DetectSGA doesn't find the SGA
hardware, it returns a value of -11 (grError) and InitGraph proceeds with
its normal hardware detection logic (which might include calling any
other vendor-supplied auto detection functions in the order in which they
were "installed"). If, however, DetectSGA determines that an SGA is
present, it returns a nonnegative mode number, and InitGraph locates and
loads SGA.BGl, puts the hardware into the default graphics mode recommended by DetectSGA, and finally returns control to your program.
See also
Example
uses Graph;
var
Driver, Mode,
TestDriver,
ErrCode: Integer;
{$F+}
95
III
InstaliUserDriver function
begin
Writeln(/Error during Init:
ErrCode};
Halt (1);
end;
OutText(/Installable drivers supported . .. /};
Readln;
CloseGraph;
end.
I
Graph
InstaliUserFont function
Purpose
Declaration
96
Remarks
See also
Example
uses Graph;
var
Driver , Mode: Integer;
TestFont: Integer;
Programmer's Reference
InstaliUserFont function
begin
{ Install the font}
TestFont := InstallUserFont(/TEST / );
if GraphResult <> grOk then
begin
Writeln(/Error installing TestFont (using DefaultFont) ');
Readln;
end;
Driver := Detect;
{ Put in graphics mode }
InitGraph(Driver , Mode, ");
if GraphResult <> grOk then
Halt (1);
SetTextStyle(TestFont , HorizDir , 2);
{ Use new font }
OutText(/Installable fonts supported ... ');
Readln;
CloseGraph;
end.
Int function
Purpose
Declaration
System
Returns the integer part of the argument.
function Int (X: Real): Real;
Remarks
See also
Example
var R: Real;
begin
R := Int(123.456);
R := Int(-123.456);
end.
Intr procedure
Purpose
Declaration
Dos WinDos
1
Remarks
{ 123.0
{ -123.0
{Dos}
{WinDos}
97
Intr procedure
Before executing the specified software interrupt, Intr loads the 8086
CPU's AX, BX, CX, DX, BP, 51, DI, DS, and ES registers from the Regs
record. When the interrupt completes, the contents of the AX, BX, CX, DX,
BP, 51, DI, DS, ES, and Flags registers are stored back into the Regs record.
For details on writing interrupt procedures, see the section "Interrupt
handling" in Chapter 20 of the Language Guide.
Restrictions
See also
System
IOResult function
Purpose
Declaration
Remarks
Example
See also
98
FileSize(F))
InOutRes
Programmer's Reference
Justification constants
Justification constants
Purpose
Graph
Remarks
Constant
Value
LeftText
CenterText
RightText
BottomText
CenterText
Top Text
See also
1
2
SetTextJustify
Keep procedure
Purpose
Declaration
Remarks
Restrictions
See also
Declaration
Dos
Keep (or terminate and stay resident) terminates the program and makes it
stay in memory.
procedure Keep (Exi tCode: Word);
KeyPressed function
Purpose
III
1
2
Crt
Returns True if a key has been pressed on the keyboard; False otherwise.
function KeyPressed: Boolean;
Remarks
The character (or characters) is left in the keyboard buffer. KeyPressed does
not detect shift keys like Shift, Aft, NumLock, and so on.
See also
ReadKey
99 .
KeyPressed function
Example
uses' Crt;
begin
repeat
Write( 'Xx');
until KeYPressed;
end.
LastMode variable
Purpose
Declaration
Crt
Remarks
See also
TextMode
Length function
Purpose
Declaration
System
Remarks
See also
Example
var S: String;
begin
Readln(S) ;
Writeln('II', S, '"');
Writeln('length = " Length(S));
end.
Line procedure
Purpose
Declaration
Remarks
100
Graph
Draws a line in the style and thickness defined by SetLineStyle and uses
the color set bySetColor. Use SetWriteMode to determine whether the line
is copied or XORed to the screen.
Programmer's Reference
Line procedure
Note that
MoveTo(100, 100);
LineTo(200, 200);
is equivalent to
Line(100, 100, 200, 200);
MoveTo(200, 200);
Use LineTo when the current pointer is at one endpoint of the line. If you
want the current pointer updated automatically when the line is drawn,
use LineRel to draw a line a relative distance from the CPo Note that Line
doesn't update the current pointer.
Restrictions
Must be in graphics mode. Also, for drawing a horizontal line, Bar is faster
than Line.
See also
Example
Halt(l);
Randomize;
repeat
Line (Random(200), Random(200) , Random(200) , Random(200));
until KeyPressedi
Readlni
CloseGraph;
end.
Graph
Value
SolidLn
DottedLn
CenterLn
DashedLn
2
3
101
UserBitLn
Norm Width
ThickWidth
See also
LineSettingsType
Graph
LineRel procedure
Purpose
Draws a line to a point that is a relative distance from the current pointer
(CP).
Declaration
Remarks
Dy:
Integer);
LineRel will draw a line from the current pomter to a point that is a
relative (Dx, Dy) distance from the current pointer. The current line style
and pattern, as set by SetLineStyle, are used for drawing the line and uses
the color set by SetColor. Relative move and line commands are useful for
drawing a shape on the screen whose starting point can be changed to
draw the same shape in a different location on the screen. Use
SetWriteMode to determine whether the line is copied or XORed to the
screen.
The current pointer is set to the last point drawn by LineRel.
Restrictions
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd :=Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
MoveTo(l, 2);
LineRel(100, 100);
Readln;
CloseGraph;
end.
102
Programmer's Reference
LineSeHingsType type
LineSettingsType type
Purpose
Declaration
Graph
The record that defines the style, pattern, and thickness of a line.
type
LineSettingsType= record
LineStyle: Word;
Pattern: Word;
Thickness: Word;
end;
Remarks
See Line style constants for a list of defined line styles and thickness values.
See also
GetLineSettings, SetLineStyle
_Li_n_e_To__p_ro__
c_e_d_u_re______________________________~__G
__ra_p__h
Purpose
Declaration
Remarks
Draws a line in the style and thickness defined by SetLineStyle and uses
the color set by SetColor. Use SetWriteMode to determine whether the line
is copied or XORed to the screen.
Note that
MoveTo(100, 100);
LineTo(200, 200);
is equivalent to
Line(100, 100, 200, 200);
The first method is slower and uses more code. Use LineTo only when the
current pointer is at one endpoint of the line. Use LineRel to draw a line a
relative distance from the CPo Note that the second method doesn't
change the value of the current pointer.
See also
Example
103
LineTo procedure
begin
Gd : = Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
Randomize;
repeat
LineTo(Random(200) , Random(200));
until KeyPressed;
Readln;
CloseGraph;
end.
Ln function
Purpose
Declaration
System
Returns the natural logarithm of the argument.
function Ln(X: Real): Real;
Remarks
See also
Exp
Lo function
Purpose
Declaration
System
Returns the low-order byte of the argument.
function Lo (X): Byte;
Remarks
See also
Hi, Swap
:=
Lo($1234);
{$34}
Low function
Purpose
Declaration
Result type
104
System
Returns the lowest value in the range of the argument.
function Low (X) ;
Programmer's Reference
Low function
Remarks
See also
High
Example
var
A: array[l .. 100] of Integeri
I: Integer;
begin
for I := Low(A) to High(A) do A[I] := Oi
end.
type
TDay = (Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, SundaY)i
const
DayNarne: array [TDay] of string[3] = (
'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
var
Day: TDaYi
Hours: array [TDay] of 0 .. 24i
begin
for Day := Low (TDay) to High (TDay) do
begin
Write('Hours worked on " DayNarne[Day] , '7 ')i
Readln(Hours[Day]) i
endi
end.
LowVideo procedure
Purpose
Declaration
Crt
Remarks
See also
105
LowVideo procedure
Example
uses Crt;
begin
TextAttr := White;
LowVideo;
end.
Printer
Lst variable
Purpose
Declaration
Remarks
See also
Assign, Rewrite
Example
program Print It ;
var
Lst: Text;
begin
Assign(Lst, 'LPT1');
Rewrite (Lst) ;
Writeln(Lst, 'Hello printer.');
Close(Lst)
end.
MaxAvail function
Purpose
Declaration
Remarks
System
Returns the size of the largest contiguous free block in the heap,
corresponding to the size of the largest dynamic variable that can be
allocated at that time.
function MaxAvail: Longint;
MaxAvail returns the size of the largest contiguous free block in the heap,
corresponding to the size of the largest dynamic variable that can be
allocated at that time using New or GetMem. To find the total amount of
free memory in the heap, call MemAvail.
MaxAvail compares the size of the largest free block below the heap
pointer to the size of free memory above the heap pointer, and returns the
larger of the two values. Your program can specify minimum and
maximum heap requirements using the $M directive.
See also
106
MemAvail
Programmer's Reference
MaxAvaii function
Example
type
PBuffer = ATBuffer;
TBuffer = array[O .. 163831 of Char;
var Buffer: PBuffer;
begin
if MaxAvail < SizeOf(TBuffer) then OutOfMernory else
begin
New (Buffer) ;
end;
end.
MaxColors constant
Purpose
Declaration
See also
Graph
= 15;
MemAvail function
Purpose
Declaration
Remarks
System
MernAvail returns the sum of the sizes of all free blocks in the heap. Note
that a contiguous block of storage the size of the returned value is
unlikely to be available due to fragmentation of the heap. To find the
largest free block, call MaxAvail.
MemAvail is calculated by adding the sizes of all free blocks below the
heap pointer to the size of free memory above the heap pointer. Your
program can specify minimum and maximum heap requirements using
the $M directive.
See also
MaxAvail
107
II
MemAvaii function
Example
begin
Writeln(MemAvail, , bytes available');
Writeln('Largest free block is " MaxAvail, , bytes');
end.
System
MkDir procedure
Purpose
Declaration
Remarks
Creates a subdirectory.
procedure MkDir (S: String);
Creates a new subdirectory with the path specified by string S. The last
item in the path cannot be an existing file name.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
See also
ChDir, GetDir, RmDir. CreateDir performs the same function as MkDir, but
it takes a null-terminated string rather than a Pascal-style string.
Example
begin
{$I-}
MkDir(ParamStr(l)) ;
if IOResult <> 0 then
Wri teln,( , Cannot create directory')
else
Writeln('New directory created');
end.
System
Move procedure
Purpose
Declaration
Remarks
Source and Dest are variable references of any type. Count is an expression
of type Word. Move copies a block of Count bytes from the first byte
occupied by Source to the first byte occupied by Dest. No checking is
performed, so be careful with this procedure.
I
When Source and Dest are in the same segment, that is, when the segment
parts of their addresses are equal, Move automatically detects and
compensates for any overlap. Intrasegment overlaps never occur on
108
Programmer's Reference
Move procedure
FillChar
Example
var
A: array[l .. 4J of Char;
B: Longint;
begin
Move (A, B, SizeOf(A));
end.
{ SizeOf = safety! }
Graph
MoveRel procedure
Purpose
Declaration
Remarks
Moves the current pointer (CP) a relative distance from its current
location.
procedure MoveRel (Dx,
Dy:
Integer);
commands are useful for drawing a shape on the screen whose starting
point can be changed to draw the same shape in a different location on the
screen.
Restrictions
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
MoveTo(l, 2);
MoveRel(lO, 10);
Put Pixel (GetX, Gety, GetMaxColor);
Readln;
CloseGraph;
end.
109
MoveTo procedure
Graph
MoveTo procedure
Purpose
Declaration
Remarks
The CP is similar to a text mode cursor except that the CP is not visible.
The following routines move the CP:
Clear Device
Clear ViewPort
GraphDefaults
InitGraph
OutText
SetGraphMode
Set ViewPort
LineRel
LineTo
MoveRel
MoveTo
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
MoveTo(O, 0);
LineTo(GetMaxX, GetMaxY);
Readln;
CloseGraph;
end.
MsDos procedure
Purpose
Declaration
110
Dos, WinDos
Remarks
{Dos}
{WinDos}
The effect of a call to MsDos is the same as a call to Intr with an IntNo of
$21. Registers is a record defined in the Dos unit. TRegisters is defined in
the WinDos unit. See page 141 for the declaration of Registers and page 198
for the declaration of TRegisters.
Programmer's Reference
MsDos procedure
Restrictions
See also
System
New procedure
Purpose
Declaration
Remarks
Creates a new dynamic variable and sets a pointer variable to point to it.
procedure New(var P: Pointer [
Init: Constructor 1 )i
P is a variable of any pointer type. The size of the allocated memory block
corresponds to the size of the type that P points to. The newly created
variable can be referenced as PA. If there isn't enough free space in the
heap to allocate the new variable, a run-time error occurs. (It is possible to
avoid a run-time error in this case; see "The HeapError variable" in
Chapter 19 in the Language Guide.)
NormVideo procedure
Purpose
Declaration
Crt
Selects the original text attribute read from the cursor location at startup.
procedure NorrnVideo i
Remarks
See also
111
II
NoSound procedure
NoSound procedure
Purpose
Declaration
Remarks
Crt
The following program fragment emits a 440-hertz tone for half a second:
Sound(440);
Delay(500);
NoSound;
See also
Sound
Odd function
Purpose
Declaration
Remarks
System
Tests if the argument is an odd number.
function Odd (X: Longint): Boolean;
Ofs function
Purpose
Declaration
System
Returns the offset of a specified object.
function Ofs (X): Word;
Remarks
Restrictions
See also
Addr, Seg
Ord function
Purpose
Declaration
112
System
Returns the ordinal value of an ordinal-type expression.
function Ord (X): Longint;
Programmer's Reference
Ord function
Remarks
See also
Chr
Output variable
Purpose
Declaration
Remarks
System
See also
Input
OutText procedure
Purpose
Declaration
Remarks
Graph
OutText uses the font set by SetTextStyle. In order to maintain code compatibility when using several fonts, use the TextWidth and TextHeight calls
to determine the dimensions of the string.
OutText uses the output options set by SetTextJustify (justify, center, rotate
90 degrees, and so on).
The current pointer (CP) is updated by OutText only if the direction is
horizontal, and the horizontal justification is left. Text output direction is
113
OutText procedure
MoveTo(O, 0);
SetTextStyle(DefaultFont, HorizDir, 1);
SetTextJustify(LeftText, TopTe~t);
OutText (' ABC') ;
OutText ('DEF') ;
{ CharSize = 1 }
{ CP is updated }
{ CP is updated }
{ #2 }
MoveTo(100, 50);
SetTextStyle(DefaultFont, HorizDir, 1);
SetTextJustify(RightText, TopText);
OutText (' ABC') ;
OutText ('DEF') ;
{ CharSize = 1 }
{ CP is updated }
{ CP is updated }
{ #3 }
MoveTo(100, 100);
SetTextStyle(DefaultFont, VertDir, 1);
SetTextJustify(LeftText, TopText)i
OutText (' ABC') i
OutText ( 'DEF') i
Readlni
CloseGraphi
end.
{ CharSize = 1 }
{ CP is NOT updated }
{ CP is NOT updated }
114
Programmer's Reference
OutText procedure
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
OutText('Easy to use');
Readln;
CloseGraph;
end.
OutTextXy procedure
Purpose
Declaration
Remarks
Graph
Restrictions
115
OutTextXY procedure
See also
Example
uses Graph;
var
Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
MoveTo(O, 0);
OutText('Inefficient');
Readln;
OutTextXY(GetX, GetY, 'Also inefficient');
Readln;
ClearDevice;
OutTextXY(O, 0, 'Perfect!');
Readln;
CloseGraph;
end.
OvrClearBuf procedure
Purpose
Declaration
Remarks
{ Replaces above }
Overlay
Disposes of all currently loaded overlays from the overlay buffer. This
forces subsequent calls to overlaid routines to reload the overlays from
the overlay file (or from EMS). If OvrClearBufis called from an overlay,
that overlay will immediately be reloaded upon return from OvrClearBuf
The overlay manager never requires you to call OvrClearBuf; in fact, doing
so will decrease performance of your application, since it forces overlays
to be reloaded. OvrClearBufis solely intended for special use, such as
temporarily reclaiming the memory occupied by the overlay buffer.
See also
OvrGetBuf, OvrSetBuf
OvrCodeList variable
Purpose
Declaration
116
System
Programmer's Reference
OvrCodeList variable
Remarks
OvrDebugptr variable
Purpose
Declaration
Remarks
OvrDosHandle variable
Purpose
Declaration
Remarks
See also
System
System
OvrEmsHandle variable
Purpose
Declaration
System
Remarks
See also
Overlnit,OverlnitEMS
117
OvrFileMode variable
OvrFileMode variable
Purpose
Declaration
Overlay
Determines the access code to pass to DOS when the overlay file is
opened.
var OvrFileMode: Byte;
Remarks
See also
Ovrlnit
Overlay
OvrGetBuf function
Purpose
Declaration
Remarks
The size of the overlay buffer is set through a call to OvrSetBuf Initially,
the overlay buffer is as small as possible, corresponding to the size of the
largest overlay. When an overlajd program is executed, a buffer of this
size is automatically allocated. Because it includes both code and fix-up
information for the largest overlay, however, the initial buffer size could
be larger than 64K.
See also
Example
{$M 16384,65536,655360}
uses Overlay;
const ExtraSize = 49152; {48K}
begin
Ovrlnit('EDITOR.OVR');
Writeln('Initial size of overlay buffer is " OvrGetBuf,' bytes.');
OvrSetBuf(OvrGetBuf+ExtraSize);
Writeln('Overlay buffer now increased to " OvrGetBuf,' bytes.');
end.
OvrGetRetry function
Purpose
Declaration
118
Overlay
Programmer's Reference
OvrGetRetry function
Remarks
OvrGetRetry returns the current size of the probation area which is the
value last set with OvrSetRetry.
See also
OvrSetRetry
OvrHeapEnd variable
Purpose
Declaration
System
Remarks
OvrHeapEnd stores the segment address of the end of the overlay buffer.
Except as specified in the description of OvrHeapOrg, you should never
modify OvrHeapEnd.
See also
OvrHeapOrg, OvrSetBuf
OvrHeapOrg variable
Purpose
Declaration
Remarks
System
OvrHeapOrg stores the segment address of the start of the overlay buffer.
The run-time library's start-up code initializes OvrHeapOrg, OvrHeapPtr,
and OvrHeapEnd to point to an overlay buffer between the program's stack
segment and heap. The size of this initial overlay buffer (in 16-byte
paragraphs) is given by the OvrHeapSize variable, and it corresponds to
the size of the largest overlay in the program, including fixup information
for the overlay.
.
It is possible for a program to move the overlay buffer to another location
119
II
OvrHeapPtr variable
OvrHeapPtr variable
Purpose
Declaration
. Remarks
See also
System
OvrHeapSize variable
Purpose
Declaration
System
Remarks
See also
OvrHeapOrg
Ovrlnit procedure
Purpose
Declaration
Remarks
Overlay
searches for the file in the current directory, in the directory that contains
the .EXE file (if running under DOS 3.x or later), and in the directories
specified in the PATH environment variable.
Errors are reported in the OvrResult variable. ovrOk indicates success.
ovrError means that the overlay file is of an incorrect format, or that the
program has no overlays. ovrNotFound means that the overlay file could
not be located.
In case of error, the overlay manager remains uninstalled, and an attempt
to call an overlaid routine win produce run-time error 208 ("Overlay
manager not installed").
120
Programmer's Reference
Ovrlnit procedure
Example
end;
end.
OvrlnitEMS procedure
Purpose
Declaration
Remarks
Overlay
See also
121
OvrlnitEMS procedure
Example
uses Overlay;
begin
OvrInit(/EDITOR.OVR / };
if OvrResult <> ovrOk then
begin
Writeln(/Overlay manager initialization failed. I};
Halt(l} ;
end;
OvrInitEMS;
case OvrResult of
ovrIOError: Writeln(/Overlay file I/O error. I};
ovrNoEMSDriver: Writeln( I EMS driver not installed. I};
ovrNoEMSMemory: Writeln(/Not enough EMS memory. I};
else Writeln(/Using EMS for faster overlay swapping. I};
end;
end;
OvrLoadCount variable
Purpose
Declaration
Remarks
Overlay
OvrLoadList variable
Purpose
Declaration
Remarks
122
System
Programmer's Reference
OvrReadBuf variable
OvrReadBuf variable
Purpose
Declaration
Remarks
OvrResult variable
Purpose
Declaration
Overlay
Overlay
Remarks
Before returning, each of the procedure in the Overlay unit stores a result
code in the ovrResult variable. Possible OvrXXXX return codes are listed
on page 125. In general, a value of zero indicates success. The OvrResult
variable resembles the IOResult standard function except that OvrResult is
not set to zero once it is accessed. Thus, there is no need to copy OvrResult
into a local variable before it is examined.
See also
OvrSetBuf procedure
Purpose
Declaration
Remarks
Overlay
BufSize must be larger than or equal to the initial size of the overlay buffer,
and less than or equal to MemAvail + OvrGetBuf The initial size of the
overlay buffer is the size returned by OvrGetBufbefore any calls to
OvrSetBuf
123
OvrSetBuf procedure
If the specified size is larger than the current size, additional space is
allocated from the beginning of the heap, thus decreasing the size of the
heap. Likewise, if the specified size is less than the current size, excess
space is returned to the heap.
OvrSetBuj requires that the heap be empty; an error is returned if dynamic
variables have already been allocated using New or GetMem. For this
reason, make sure to call OvrSetBujbefore the Graph unit's InitGraph
procedure; InitGraph allocates memory on the heap and-once it has done
so-all calls to OvrSetBuj will be ignored.
If you are using OvrSetBuj to increase the size of the overlay buffer, you
should also include a $M compiler directive in your program to increase
the minimum size of the heap accordingly.
Example
Overlay
OvrSetRetry procedure
Purpose
Declaration
~emarks
If an overlay falls within the Size bytes before the overlay buffer tail, it is
automatically put on probation. Any free space in the overlay buffer is
considered part of the probation area. For reasons of compatibility with
earlier versions of the overlay manager, the default probation area size is
zero, which effectively disables the probation/reprieval mechanism.
124
Programmer's Reference
OvrSetRetry procedure
See also
OvrGetRetry
Example
I );
OvrTrapCount variable
Purpose
Declaration
Overlay
Remarks
See also
OvrLoadCount
ovrXXXX constants
Purpose
Overlay
Remarks
Constant
ovrOk
ovrError
ovrNotFound
ovrNoMemory
ovrIOError
ovrNoEMSDriver
ovrNoEMSMemory
Value
o
-1
-2
-3
-4
-5
-6
Meaning
Success
Overlay manager error
Overlay file not found
Not enough memory for overlay buffer
Overlay file 1/ 0 error
EMS driver not installed
Not enough EMS memory
PackTime procedure
Purpose
Declaration
Dos, WinDos
{Dos}
{WinDos}
125
PackTime procedure
Remarks
See also
Graph
PaletteType type
Purpose
Declaration
The record that defines the size and colors of the palette; used by
GetPalette, GetDejaultPalette, and SetAllPalette.
type
PaletteType = record
Size: Byte;
Colors: array[O .. MaxColors] of Shortint;
end;
The size field reports the number of colors in the palette for the current
driver in the current mode. Colors contains the actual colors O.. Size - 1.
System
ParamCount function
Purpose
Declaration
126
Remarks
See also
ParamStr
Programmer's Reference
ParamCount function
Example
begin
if ParamCount = 0 then
Writeln('No parameters on command line')
else
Writeln(ParamCount, , parameter(s)');
end.
ParamStr function
Purpose
Declaration
System
Remarks
See also
ParamCount
Example
var I: Word;
begin
for I := 1 to ParamCount do
Writeln(ParamStr(I) );
end.
Pi function
Purpose
Declaration
Remarks
System
Returns the value of pi (3.1415926535897932385).
function Pi: Real;
PieSlice procedure
Purpose
Declaration
Remarks
Graph
Draws and fills a pie slice, using (X, Y) as the center point and drawing
from start angle to end angle.
procedure PieS lice (X, Y: Integer; StAngle, EndAngle, Radius: Word);
The pie slice is outlined using the current color, and filled using the
patternand color defined by SetFillStyle or SetFillPattern.
127
PieSlice procedure /
Each graphics driver contains an aspect ratio that is used by Circle, Arc,
and PieS lice. A start angle of 0 and an end angle of 360 will draw and fill a
complete circle. The angles for Arc, Ellipse, and PieS lice are counterclockwise with 0 degrees at 3 a' clock, 90 degrees at 12 a' clock, and so on.
If an error occurs while filling the pie slice, GraphResuU returns a value of
grNoScanMem.
Restrictions
See also
Example
uses Graph;
const Radius = 30;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
PieSlice(100, 100, 0, 270, Radius);
Readln;
CloseGraph;
end.
PointType type
Purpose
Declaration
type
PointType = record
X, Y: Integer;
end;
System
Purpose
D.eclaration
Remarks
Graph
A type defined for your convenience. Both fields are of type Integer rather
than Word.
Pas function
128
Substr and S are string-type expressions. Pos searches for Substr within S,
and returns an integer value that is the index of the first character of
Substr within S. If Substr is not found, Pos returns zero.
Programmer's Reference
Pos function
See also
Example
var S: String i
begin
S .-
123.S ' i
while POS('
S) > 0 do
S[POS(' " S)] := 'O'i
end.
I I
Pred function
Purpose
Declaration
System
Returns the predecessor of the argument.
function Pred (X)
Remarks
See also
PrefixSeg variable
Purpose
Declaration
Remarks
System
For a complete description of the Program Segment Prefix, see your DOS
manuals.
Ptr function
Purpose
Declaration
Remarks
System
Converts a segment base and an offset address to a pointer-type value.
function Ptr(Seg , Ofs: Word): Pointeri
Seg and Ofs are expressions of type Word. The result is a pointer that
points to the address given by Seg and Ofs. Like nil, the result of Ptr is
assignment compatible with all pointer types.
The function result can be dereferenced and typecast:
if Byte(Ptr(Seg0040 , $49)")
Writeln(/Video mode
See also
= 7 then
= mono/)i
129
Ptr function
Example
var P: AByte;
begin
P := Ptr(Seg0040, $49);
Writeln('Current video mode is'
end.
PAl;
Putlmage procedure
Purpose
Declaration
Remarks
Graph
(X, Y) is the upper left corner of a rectangular region on the screen. BitMap
is an untyped parameter that contains the height and width of the region,
and the bit image that will be put onto the screen. BitBlt specifies which
binary operator will be used to put the bit image onto the screen. See
page 12 for a list of BitBlt operators.
Each constant corresponds to a binary operation. For example,
PutImage(X, Y, BitMap, NorrnalPut) puts the image stored in BitMap at
(X, Y) using the assembly language MOV instruction for each byte in the
image.
Similarly, PutImage(X, Y, BitMap, XORPut) puts the image stored in
BitMap at (X, Y) using the assembly language XOR instruction for each
byte in the image. This is an often-used animation technique for
"dragging" an image around the screen.
PutImage(X, Y, BitMap, NotPut) inverts the bits in BitMap and then puts
the image stored in BitMap at (X, Y) using the assembly language MOV for
each byte in the image. Thus, the image appears in inverse video of the
original BitMap.
Note that PutImage is never clipped to the viewport boundary.
Moreover-with one exception-it is not actually clipped at the screen
edge either. Instead, if any part of the image would go off the screen, no
image is output. In the following example, the first image would be
output, but the middle three PutImage statements would have no effect:
program NoClipi
uses Graphi
var
Driver, Mode: Integer;
P: Pointer;
130
Programmer's Reference
Putlmage procedure
begin
Driver := Detect;
InitGraph(Driver, Mode, "};
if GraphResult < 0 then
Halt (1);
SetViewPort(O, 0, GetMaxX, GetMaxY, ClipOn};
GetMem(p, ImageSize(O, 0, 99, 49}};
PieSlice(50, 25, 0, 360, 45};
GetImage(O, 0, 99, 49, PAl;
ClearDevice;
PutImage(GetMaxX - 99, 0,
pA, NormalPut};
PutImage(GetMaxX - 98, 0,
pA, NormalPut};
PutImage (-1, 0,
pA, NormalPut);
PutImage (0, -1,
pA, NormalPut);
Put Image (0, GetMaxY - 30,
pA, NormalPut};
Readln;
CloseGraph;
end.
In the last PutImage statement, the height is clipped at the lower screen
edge, and a partial image is displayed. This is the only time any clipping
is performed on PutImage output.
Restrictions
See also
Example
uses Graph;
var
Gd, Gm: Integer;
P: Pointer;
Size: Word;
begin
Gd := Detect;
InitGraph(Gd, Gm, "};
if GraphResult <> grOk then
Halt(l} ;
Bar(O, 0, GetMaxX, GetMaxY};
Size := ImageSize(10, 20, 30, 40};
GetMem(P, Size};
Get Image (10, 20, 30, 40, PA};
Readln;
ClearDevice;
131
Putlmage procedure
PutPixel procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Plots a pixel at X, Y.
procedure Putpixel (X, Y: Integer; Pixel: Word);
~t (X,
Y).
See also
Example
Color := GetMaxColor;
Randomize;
repeat
PutPixel(Random(100), Random(100), Color);
Delay(10) ;
until KeyPressed;
Readln;
CloseGraph;
end.
Random function
Purpose
Declaration
Result type
Remarks
132
{ Plot "stars" }
System
Programmer's Reference
Random function
type Word, and the result is a Word-type random number within the range
a <= X < Range. If Range equals 0, a value of ais returned.
The random number generator should be initialized by making a call to
Randomize, or by assigning a value to RandSeed.
See also
Randomize
System
Randomize procedure
Purpose
Declaration
Remarks
The random value is obtained from the system clock. The random number
generator's seed is stored in a predeclared Longint variable called
RandSeed.
See also
Random
System
RandSeed variable
Purpose
Declaration
Remarks
See also
Random, Randomize
System
Reads one or more values from a text file into one or more variables.
procedure Read ( [ var F: Text; 1 V1 [f V2f
f VN 1 );
133
character) is assigned to the variable. The next Read starts with the next
character in the file.
With a type integer variable, Read expects a sequence of characters that
form a signed whole number according to the syntax illustrated in
section "Numbers" in Chapter 2 of the Language Guide. Any blanks,
.tabs, or end-of-line markers preceding the numeric string are skipped.
Reading ceases at the first blank, tab, or end-of-line marker following
the numeric string or if Eof(F) becomes True. If the numeric string does
not conform to the expected format, an I/O error occurs; otherwise; the
value is assigned to the variable. If Eof(F) was True before Read was
executed or if Eof(F) becomes True while skipping initial blanks, tabs,
and end~of-line markers, the value 0 is assigned to the variable. The
next Read will start with the blank, tab, or end-of-line marker that
terminated the numeric string.
With a type real variable, Read expects a sequence of characters that
form a signed whole number (except that hexadecimal notation is not
allowed). Any blanks, tabs, or end-of-line markers preceding the
numeric string are skipped. Reading ceases at the first blank, tab, or
end-of-line marker following the numeric string or if Eof(F) becomes
True. If the numeric string does not conform to the expected format, an
I/O error occurs; otherwise, the value is assigned to the variable. If
Eof(F) was True before Read was executed, or if Eof(F) becomes True
while skipping initial blanks, tabs, and end-of-line markers, the value 0
is assigned to the variable. The next Read will start with the blank, tab,
or end-of-line marker that terminated the numeric string.
With a type string variable, Read reads all characters up to, but not
including, the next end-of-line marker or until Eof(F) becomes True. The
resulting character string is assigned to the variable. If the resulting .
string is longer than the maximum length of the string variable, it is
truncated. The next Read will start with the end-of-line marker that
terminated the string.
When the extended syntax is enabled, Read can also be used to read
null-terminated strings into zero-based character arrays. With a
character array of the form array[O .. N] of Char, Read reads up to N
characters, or until Eoln(F) or Eof(F) become True, and then appends a
NULL (#0) terminator to the string.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Restrictions
134
Re.ad with a type string variable does not skip to the next line after
reading. For this reason, you cannot use successive Read calls to read a
sequence of strings because you'll never get past the first line; after the
Programmer's Reference
first Read, each subsequent Read will see the end-of-line marker and return
a zero-length string. Instead, use multiple Readln calls to read successive
string values.
See also
System
[,
V2'
, VN
1 )i
F is a file variable of any type except text, and each V is a variable of the
same type as the component type of F. For each variable read, the current
file position is advanced to the next component. An error occurs if you
attempt to read from a file when the current file position is at the end of
the file; that is, when Eof(F) is True.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Restrictions
See also
Write
ReadKey function
Purpose
Declaration
Remarks
Crt
The character read is not echoed to the screen. If KeyPressed was True
before the call to ReadKey, the character is returned immediately.
Otherwise, ReadKey waits for a key to be typed.
The special keys on the PC keyboard generate extended scan codes.
Special keys are the function keys, the cursor control keys, Alt keys, and so .
on. When a special key is pressed, ReadKey first returns a null character
(#0), and then returns the extended scan code. Null characters cannot be
generated in any other way, so you are guaranteed the next character will
be an extended scan code.
The following program fragment reads a character or an extended scan
code into a variable called Ch and sets a Boolean variable called FuncKey
to True if the character is a special key:
135
ReadKey function
Ch : = ReadKey;
if Ch <> #0 then FuncKey := False else
begin
FuncKey : = True;
Ch : = ReadKey;
end;
Key Pressed
System
Readln procedure
Purpose
Declaration
Remarks
Executes the Read procedure then skips to the next line of the file.
procedure Readln ( [ var F: Text;
1 vi [, V2'
, VN
1 );
Restrictions
See also
Read
Graph
Rectangle procedure
Purpose
Declaration
Remarks
(Xl, Yl) define the upper left corner of the rectangle, and (X2, Y2)
define the lower right comer (0 <= Xl < X2 <= GetMaxX, and
o <= Yl < Y2 <= GetMaxY).
Draws the rectangle in the current line style and color, as set by
SetLineStyle and SetColor. Use SetWriteMode to determine whether the
rectangle is copied or XORed to the screen.
136
Programmer's Reference
Rectangle procedure
Restrictions
See also
Example
Randomize;
repeat
Xl := Random(GetMaxX);
Y1 := Random(GetMaxY);
X2 := Random(GetMaxX - Xl) + Xl;
Y2 := Random(GetMaxY - Y1) + Y1;
Rectangle (Xl, Y1, X2, Y2);
until KeyPressed;
CloseGraph;
end.
RegisterBGldriver function
Purpose
Declaration
Remarks
Graph
If an error occurs, the return value is less than 0; otherwise, the internal
driver number is returned.
This routine enables a user to load a driver file and "register" the driver
by passing its memory location to RegisterBGldriver. When that driver is
used by InitGraph, the registered driver will be used (instead of being
loaded from disk by the Graph unit). A user-registered driver can be
loaded from disk onto the heap, or converted to an .OBJ file (using
BINOBJ .EXE) and linked into the .EXE.
Returns grlnvalidDriver if the driver header is not recognized.
The following program loads the eGA driver onto the heap, registers it
with the graphics system, and calls InitGraph:
137
RegisterBGldriver function
program LoadDriv;
uses Graph;
var
Driver, Mode: Integer;
DriverF: file;
DriverP: Pointer;
begin
{ Open driver file, read into memory, register it }
Assign (DriverF, 'CGA.BGI'};
Reset (DriverF, 1};
GetMem(DriverP, FileSize(DriverF}};
BlockRead(DriverF, DriverP A , FileSize(DriverF}};
if RegisterBGldriver(DriverP} < 0 then
begin
Writeln('Error registering driver: '
GraphErrorMsg(GraphResult}};
Halt (1) ;
end;
{ Init graphics
Driver := CGA;
Mode : = CGAHi;
InitGraph(Driver, Mode, "} i
if GraphResul t < 0 then
Halt (1);
OutText('Driver loaded by user program'};
Readlni
CloseGraphi
end.
The program begins by loading the eGA driver file from disk and
registering it with the Graph unit~ Then a call is made to InitGraph to
initialize the graphics system. You might wish to incorporate one or more
driver files directly into your .EXE file. In this way, the graphics drivers
that your program needs will be built-in and only the .EXE will be needed
in order to run. The process for incorporating a driver file into your .EXE
is straightforward:
1. ~un BINOBJ on the driver file(s).
2. Link the resulting .OBJ file(s) into your program.
3. Register the linked-in driver file(s) before calling InitGraph.
138
Programmer's Reference
RegisterBGldriver function
RegisterBGIfont.
Restrictions
See also
Note that the driver must be registered before the call to InitGraph. If a call
is made to RegisterBGldriver once graphics have been activated, a value of
grError will be returned. If you want to register a user-provided driver,
you must first call InstallUserDriver, then proceed as described in the
previous example.
RegisterBGlfont function
Purpose
Declaration
Remarks
Graph
The return value is less than 0 if an error occurs. Possible error codes are
grError, grlnvalidFont, and grlnvalidFontNum. If no error occurs, the
internal font number is returned. This routine enables a user to load a font
file and "register'~ the font by passing its memory location to
RegisterBGIfont. When that font is selected with a call to SetTextStyle, the
registered font will be used (instead of being loaded from disk by the
Graph unit). A user-registered font can be loaded from disk onto the heap,
or converted to an .OBJ file (using BINOBJ.EXE) and linked into the .EXE.
There are several reasons to load and register font files. First, Graph only
keeps one stroked font in memory at a time. If you have a program that
needs to quickly alternate between stroked fonts, you might want to load
and register the fonts yourself at the beginning of your program. Then
Graph will not load and unload the fonts each time a call to SetTextStyle is
made.
Second, you might wish to incorporate the font files directly into your
.EXE file. This way, the font files that your program needs will be built-in,
and only the .EXE and driver files will be needed in order to run. The
process for incorporating a font file into your .EXE is straightforward:
1. Run BINOBJ on the font file(s).
139
RegisterBGlfont function
ReglsterBGldriver.
The following program loads the triplex font onto the heap, registers it
with the graphics system, and then alternates between using triplex and
another stroked font that Graph loads from disk (SansSerifFont):
program LoadFont;
uses Graph;
var
Driver, Mode: Integer;
FontF: file;
FontP: Pointer;
begin
{ Open font file, read into memory, register it }
Assign(FontF, 'TRIP.CHR');
Reset (FontF, 1);
GetMem(FontP, FileSize(FontF));
BlockRead(FontF, Fontp A , FileSize(FontF));
if RegisterBGIfont(FontP) < 0 then
begin
Writeln('Error registering font: ' GraphErrorMsg(GraphResult));
Halt (1) ;
end;
{ Init graphics
Driver := Detect;
InitGraph(Driver, Mode, ' .. \');
if GraphResult < 0 then
Halt(l) ;
Readln;
{ Select registered font
SetTextStyle(TriplexFont, HorizDir, 4);
OutText ('Triplex loaded by user program');
MoveTo(O, TextHeight('a'));
Readln;
{ Select font that must be loaded from disk }
SetTextStyle(SansSerifFont, HorizDir, 4);
OutText('Your disk should be spinning ... ');
MoveTo(O, Gety + TextHeight('a'));
Readln;
140
Programmer's Reference
RegisterBGlfont function
The program begins by loading the triplex font file from disk and
registering it with the Graph unit. Then a call to InitGraph is made to
initialize the graphics system. Watch the disk drive indicator and press
Enter. Because the triplex font is already loaded into memory and registered, Graph does not have to load it from disk (and therefore your disk
drive should not spin). Next, the program will activate the sans serif font
by loading it from disk (it is unregistered). Press Enter again and watch the
drive spin. Finally, the triplex font is selected again. Since it is in memory
and already registered, the drive will not spin when you press Enter.
See also
Registers type
Purpose
Declaration
Dos
The Intr and MsDos procedures use a variable parameter of type Registers
to specify the input register contents and examine the output register
contents of a software interrupt.
type
Registers = record
case Integer of
0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
1: (AL, AR, BL, BH, CL, CH, DL, DH: Byte);
end;
Notice the use of a variant record to map the 8-bit registers on top of their
16-bit equivalents.
See also
Intr, MsDos
RemoveDir procedure
Purpose
Declaration
Remarks
WinDos
The subdirectory with the path specified by Dir is removed. Errors, such
as a non-existing or non-empty subdirectory, are reported in the DosError
variable.
141
RemoveDir procedure
See also
System
Restrictions
See also
Erase
Reset procedure
Purpose
Declaration
Remarks
System
F is a variable of any file type associated with an external file using Assign.
RecSize is an optional expression of type Word, which can be specified only
if F is an untyped file. If F is an untyped file, RecSize specifies the record
size to be used in data transfers. If RecSize is omitted, a default record size
of 128 bytes i~ assumed.
Reset opens the existing external file with the name assigned to F. An error
results if no existing external file of the given name exists. If F is already
open, it is first closed and then reopened. The current file position is set to
the beginning of the file.
If F is assigned an empty name, such as Assign(F, If), then after the call to
Reset, F refers to the standard input file (standard handle number 0).
If F is a text file, F becomes read-only. After a call to Reset, Eof(F) is True if
the file is empty; otherwise, Eof(F) is False. .
.
142
Programmer's Reference
Reset procedure
Example
FileExists := (IOResult
endi {FileExists}
begin
if FileExists(ParamStr(l)) then
Writeln('File e~ists')
else
Writeln('File not found') i
end.
RestoreCrtMode procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Restores the screen mode to its original state before graphics mode was
initialized.
procedure RestoreCrtMode i
See also
Example
uses Graphi
var
Gd, Gm: Integeri
Mode: Integeri
begin
Gd.:= Detecti
InitGraph(Gd, Gm,
")i
143
RestoreCrtMode procedure
Rewrite procedure
Purpose
Declaration
Remarks
System
F is a variable of any file type associated with an external file using Assign.
RecSize is an optional expression of type Word, which can only be specified
if F is an untyped file. If F is an untyped file, RecSize specifies the record
size to be used in data transfers. If RecSize is omitted, a default record size
of 128 bytes is assumed.
144
Programmer's Reference
Rewrite procedure
Example
var F: Text;
begin
Assign(F, 'NEWFILE.$$$'};
Rewrite (F) ;
Writeln(F, 'Just created file with this text in it ... '};
Close (F) ;
end ..
RmDir procedure
Purpose
Declaration
Remarks
System
Removes the subdirectory with the path specified by S. If the path does
not exist, is non-empty, or is the currently logged directory, an IIO error
occurs.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
See also
Example
begin
{$I-}
RmDir(PararnStr(l}};
if IOResult <> 0 then
Writeln('Cannot remove directory'}
else
Writeln('Directory removed'};
end.
Round function
Purpose
Declaration
Remarks
I
System
145
Round function
Int, Trunc
RunError procedure
Purpose
Declaration
System
Remarks
See also
Exit, Halt
Example
{$IFDEF Debug}
if P = nil then
RunError(204) i
{$ENDIF}
SavelntXX variables
Purpose
Declaration
146
System
Type
Description
SavelntOO
Savelnt02
SavelntlB
SaveInt21
SaveInt23
Savelnt24
Savelnt34
Savelnt35
Saveint36
Savelnt37
Savelnt38
SaveInt39
Savelnt3A
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
Programmer's Reference
SavelntXX variables
Savelnt3B
Savelnt3C
Savelnt3D
SaveInt3E
Savelnt3F
Savelnt75
Remarks
Pointer
Pointer
Pointer
Pointer
Pointer
Pointer
The System unit and a number of other run-time library units take over
several interrupt vectors. The run.;.time library initialization code in the
System unit stores the old vectors in the SavelntXX variables before
installing any interrupt handling routines. Likewise, the run-time library
termination code restores the interrupt vectors using the SavelntXX
variables before returning to the operating system.
If an application needs to access the "original" interrupt vector (the one
that was in place before the run-time library installed a new interrupt
handler), it can access the corresponding SavelntXX variable. If there is no
SavelntXX variable for a particular interrupt vector, it is because the runtime library doesn't modify that vector.
See also
SearchRec type
Purpose
Declaration
Dos
SearchRec = record
Fill: array[l .. 21] of Byte;
Attr: Byte;
Time: Longint;
Size: Longint;
Name: string[12];
end;
The information for each file found by one of these procedures is reported
back in a SearchRec. The Aftr field contains the file's attributes (constructed
from file attribute constants), Time contains its packed date and time (use
UnpackTime to unpack), Size contains its size in bytes, and Name contains
its name. The Fill field is reserved by DOS and should never be modified.
147
Sector procedure
Sector procedure
Purpose
Declaration
Remarks
Graph.
Using (X, Y) as the center point, XRadius and YRadius specify the
horizontal and vertical radii, respectively; Sector draws from StAngle to
EndAngle, outlined in the current color and filled with the pattern and
color defined by SetFillStyle or SetFillPattern.
A start angle of 0 and an end angle of 360 will draw and fill a complete
ellipse. The angles for Arc, Ellipse, FillEllipse, PieS lice, and Sector are
counterclockwise with 0 degrees at3 o'clock, 90 degrees at 12 o'clock, and
soon.
See also
Example
uses Graph;
const R = 50;
var
Driver, Mode: Integer;
Xasp, Yasp: Word;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult < 0 then
Halt (1);
148
}
}
}
}
Programmer's Reference
Seek procedure
Seek procedure
Purpose
Declaration
Remarks
System
Restrictions
See also
FilePos
SeekEof function
Purpose
Declaration
Remarks
System
SeekEof corresponds to Eof except that it skips all blanks, tabs, and end-ofline markers before returning the end-of-file status. This is useful when
reading numeric values from a text file.
.
With {$I-}, IOResult returns 0 if the operation was successful; otherwise, it
returns a nonzero error code.
Restrictions
See also
Eof, SeekEoln
SeekEoln function
Purpose
Declaration
Remarks
System
SeekEoln corresponds to Eoln except that it skips all blanks and tabs before
returning the end-of-line status. This is useful when reading numeric
values from a text file.
.
149
SeekEoln function
Eoln, SeekEof
Seg function
Purpose
Declaration
System
Returns the segment of a specified object.
function Seg (Xl: Word;
Remarks
See also
Addr,Ofs
Seg0040 variable
Purpose
Declaration
Remarks
Seg0040 contains a selector that can be used to access the ROM BIOS
workspace at segment address $0040. This variable is included for compatibility between DOS real and protected mode. In real mode Seg0040
always contains the value $0040, but in protected mode the actual value
can vary.
See also
SegAOOO variable
Purpose
Declaration
Remarks
150
System
System
SegAOOO contains a selector that can be used to access the EGA and VGA
graphics memory pages at segment address $AOOO. This variable is
included for compatibility between DOS real and protected mode. In
Programmer's Reference
SegAOOO variable
real mode SegAOOO always contains the value $AOOO, but in protected
mode the actual value can vary.
See also
System
Seg8000 variable
Purpose
Declaration
Remarks
See also
System
Seg8800 variable
Purpose
Declaration
Remarks
SegBBOO contains a selector that can be used to access the Color Graphics
Adapter video memory at segment address $B800. This variable is
included for purposes of compatibility between DOS real and protected
mode. In real mode SegBBOO always contains the value $B800, but in
protected mode the actual value can vary.
See also
Seg~040,
SegAOOO, SegBOOO
Selectorlnc variable
Purpose
Declaration
Remarks
System
Selectorlnc contains the value that must be added to or subtracted from the
selector part of a pointer to incrementor decrement the pointer by 64K
bytes. In real mode, Selectorlnc always contains $1000, but in protected
mode the actual value can vary.
151
SetActivePage procedure
Graph
SetActivePage procedure
Purpose
Declaration
Remarks
Makes Page the active graphics page, directing all subsequent graphics
output to Page.
Multiple pages are supported only by the EGA (256K), VGA, and
Hercules graphics cards. With multiple graphics pages, a program can
direct graphics output to an off-screen page, then quickly display the offscreen image by changing the visual page with the SetVisualPage
procedure. This technique is especially useful for animation.
Restrictions
See also
SetVisualPage
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
if (Gd = HercMono) or (Gd = EGA) or (Gd = EGA64) or (Gd = VGA) then
begin
SetvisualPage(O);
SetActivePage(l);
Rectangle (10, 20, 30, 40);
SetVisualPage(l) ;
end
else
OutText('No paging supported.');
Readln;
CloseGraph;
end.
SetAIiPalette procedure
Purpose
Declaration
152
,Graph
Programmer's Reference
SetAIiPalette procedure
Remarks
Palette is an untyped parameter. The first byte is the length of the palette.
The next n bytes will replace the current palette colors. Each color might
range from -1 to 15. A value of -1 will not change the previous entry's
value.
Note that valid colors depend on the current graphics driver and current
, graphics mode.
If invalid input is passed to SetAllPalette, GraphResult returns a value of
-11 (grError), and no changes to the palette settings will occur.
Must be in graphics mode, and can be used only with EGA, EGA 64, or
VGA (not the IBM 8514 or the VGA in 256-color mode).
var
Gd, Gm: Integer;
Palette: PaletteType;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
153
SetAspectRatio procedure
SetAspectRatio procedure
Purpose
Declaration
Remarks
Restrictions
154
Graph
See also
GetAspectRatio
Example
Programmer's Reference
SetBkColor procedure
SetBkColor procedure
Purpose
Declaration
Remarks
Graph
SetBkColor(N) makes the Nth color in the palette the new background
color. The only exception is SetBkColor(O), which always sets the
background color to black.
Restrictions
See also
Example
SetCBreak procedure
Purpose
Declaration
I
Dos, WinDos
155
-SetCBreak procedure
Remarks
SetCBreak sets the state of Ctrl+Break checking in DOS. When off (False),
DOS only checks for Ctrl+Break during I/O to console, printer, or communication devices. When on (True), checks are made at every system call.
See also
GetCBreak
Graph
SetColor procedure
Purpose
Declaration
Remarks
SetColor(S) makes the fifth color in the palette the current drawing color.
Drawing colors might range from 0 to IS, depending on the current
graphics driver and current graphics mode.
GetMaxColor returns the highest valid color for the current driver and
mode.
Restrictions
See also
Example
Randomize;
repeat
SetColor(Random(GetMaxColor) + 1);
LineTo(Random(GetMaxX), Random(GetMaxY));
until KeyPressed;
end.
WinDos
SetCurDir procedure
Purpose
Declaration
156
Programmer's Reference
SetCurDir procedure
Remarks
If Dir specifies a drive letter, the current drive is also changed. Errors are
reported in DosError.
See also
SetDote procedure
Purpose
Declaration
Dos, WinDos
Remarks
Valid parameter ranges are Year 1980 .. 2099,Month 1..12, and Day 1..31. If
the date is invalid, the request is ignored.
See also
SetFAttr procedure
Purpose
Declaration
Remarks
Dos, WinDos
F must be a file variable (typed, untyped, or text file) that has been
assigned but not opened. The attribute value is formed by adding the
appropriate file attribute masks defined as constants in the Dos and
WinDos units. See page 43 for a list of file attribute constants.
Errors are reported in DosError; possible error codes are 3 (Invalid path)
and 5 (File access denied).
Restrictions
F cannot be open.
See also
Example
uses Dos;
var F: file;
begin
Assign(F, 'C:\AUTOEXEC.BAT');
SetFAttr(F, Hidden);
Readln;
SetFAttr(F, Archive);
end.
{ or WinDos }
{ or faHidden }
{ or faArchive }
157
SetFiliPattern procedure'
SetFiliPattern procedure
Purpose
Declaration
Remarks
Graph
Sets the pattern and color for all filling done by FillPoly, FloodFill, Bar,
Bar3D, and PieS lice to the bit pattern specified in Pattern and the color
specified by Color. If invalid input is passed to SetFillPattern, GraphResult
returns a value of grError, and the current fill settings will be unchanged.
The fill pattern is based on the underlying Byte values contained in the
Pattern array. The pattern array is 8 bytes long with each byte corresponding to 8 pixels in the pattern. Whenever a bi~ in a pattern byte is
valued at I, a pixel will be plotted. For example, the following pattern
represents a checkerboard (50% gray scale):
Binary
Hex
10101010
01010101
10101010
01010101
10101010
01010101
10101010
01010101
$AA
$55
$AA
$55
$AA
$55
$AA
$55
(1st byte)
(2nd byte)
(3rd byte)
(4th byte)
(5th byte)
(6th byte)
(7th byte)
(8th byte)
User-defined fill patterns enable you to create patterns different from the
predefined fill patterns that can be selected with the SetFillStyle
procedure. Whenever you select a new fill pattern with SetFillPattern or
SetFillStyle, all fill operations will use that fill pattern. Calling SetFillStyle
(UserField, SomeColor) will always select the user-defined pattern. This lets
you define and use a new pattern using SetFillPattern, then switch
between your pattern and the built-ins by making calls to SetTextStyle.
Restrictions
158
See also
Example
uses Graph;
const
Gray50: FillPatternType
var Gd, Gm: Integer;
Programmer's Reference
SetFiIIPaHern procedure
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
SetFillPattern(Gray50, White);
Bar (0, 0, 100, 100);
Readln;
CloseGraph;
end.
SetFiliStyle procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Sets the pattern and color for all filling done by FillPoly, Bar, Bar3D, and
PieS lice. A variety of fill patterns are available. The default pattern is solid,
and the default color is the maximum color in the palette. If invalid input
is passed to SetFillStyle, GraphResult returns a value 'of grError, and the
current fill settings will be unchanged. If Pattern equals UserFill, the userdefined pattern (set by a call to SetFillPattern) becomes the active pattern.
See page 48 for the declaration of Fill pattern constants.
Must be in graphics mode.
See also
Example
uses Graph;
var Gm, Gd: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
SetFillStyle(SolidFill, 0);
Bar (0, 0, 50, 50);
SetFillStyle(XHatchFill, 1);
Bar (60, 0, 11 0, 50);
Readln;
CloseGraph;
end.
159
SetFTime procedure
Dos, WinDos
SetFTime procedure
Purpose
Declaration
Remarks
Restrictions
See also
F must be a file variable (typed, untyped, or text file) that has been
assigned and opened. TheTime parameter can be created by calling
PackTime. Errors are reported in Dos Error; the only possible error code is 6
(Invalid file handle).
F must be open.
Graph
SetGraphBufSize procedure
Purpose
Declaration
Remarks
Lets you change the size of the buffer used for scan and flood fills.
procedure SetGraphBufSize (BufSize: Word);
Sets the internal buffer size to BufSize, and allocates a buffer on the heap
when a call is made to InitGraph.
The default buffer size is 4K, which is large enough to fill a polygon with
about 650 vertices. Under rare circumstances, you might need to enlarge
the buffer in order to avoid a buffer overflow.
Restrictions
See also
Graph
SetGraphMode procedure
Purpose
Declaration
Remarks
Mode must be a valid mode for the current device driver. SetGraphMode is
used to select a graphics mode different than the default one set by
InitGraph.
SetGraphMode can also be used in conjunction with RestoreCrtMode to
switch back and forth between text and graphics modes.
SetGraphMode resets all graphics settings to their defaults (current pointer,
palette, color, viewport, and so forth).
160
Programmer's Reference
GetModeRange returns the lowest and highest valid modes for the current
driver.
If an attempt is made to select an invalid mode for the current device
A successful call to InitGraph must have been made before calling this
routine.
See also
Example
uses Graph;
var
GraphDriver: Integer;
GraphMode: Integer;
LowMode: Integer;
HighMode: Integer;
begin
GraphDriver := Detect;
InitGraph(GraphDriver , GraphMode , ");
if GraphResult <> grOk then
Halt (1) ;
GetModeRange(GraphDriver , LowMode , HighMode);
SetGraphMode(LowMode);
Line(O, 0, GetMaxX, GetMaxY);
Readln;
CloseGraph;
end.
SetlntVec procedure
Purpose
Declaration
Remarks
Dos, WinDos
IntNo specifies the interrupt vector number (0 ..255), and Vector specifies
the address. Vector is often constructed with the @ operator to produce the
address of an interrupt procedure. Assuming Int1BSave is a variable of
type Pointer, and IntlBHandler is an interrupt procedure identifier, the
following statement sequence installs a new interrupt $1B handler and
later restores the original handler:
161
SetlntVec procedure
GetIntVec($lB, Int1BSave);
SetIntVec($lB, @Int1BHandler);
SetIntVec($lB, Int1BSave);
See also
GetIntVec
SetLineStyle procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Affects all lines drawn by Line, LineTo, Rectangle, DrawPoly, Are, and so on.
Lines can be drawn solid, dotted, centerline, or dashed. If invalid input is
passed to SetLineStyle, GraphResult returns a value of grError, and the
current line settings will be unchanged. See Line style constants for a list of
constants used to determine line styles. LineStyle is a value from SolidLn to
UserBitLn(O ..4), Pattern is ignored unless LineStyle equals UserBitLn, and
Thickness is NormWidth or ThickWidth. When LineStyle equals UserBitLn,
the line is output using the 16-bit pattern defined by the Pattern
parameter. For example, if Pattern = $AAAA, then the 16-bit pattern looks
like this:
1010101010101010
{ NormWidth }
1010101010101019
1010101010101010
1010101010101010
{ ThickWidth }
See also
Example
uses Graph;
var
162
Programmer's Reference
SetLineStyle procedure
X2 := 200;
Y2 := 150;
SetLineStyle(DottedLn, 0, NormWidth);
Rectangle (Xl, Y1, X2, Y2);
SetLineStyle(UserBitLn, $C3, ThickWidth);
Rectangle (Pred(X1) , Pred(Y1), Succ(X2), Succ(Y2));
Readln;
CloseGraph;
end.
SetPalette procedure
Purpose
Declaration
Remarks
Graph
Restrictions
Must be in graphics mode, and can be used only with EGA, EGA 64, or
VGA (not the IBM 8514).
See also
Example
Halt (1) ;
GetPalette(Palette) ;
if Palette. Size <> 1 then
163
SetPaleHe procedure
begin
for Color := 0 to Pred(Palette.Size) do
begin
SetColor(Color) ;
Line(O, Color * 5, 100, Color * 5);
end;
Randomize;
repeat
SetPalette(Random(Palette.Size),Random(Palette.Size));
until KeyPressed;
end
else
Line(O, 0, 100, 0);
Readln;
CloseGraph;
end.
i
Graph
SetRGBPalette procedure
Purpose
Declaration
Remarks
Modifies palette entries for the IBM 8514 and VGA drivers.
procedure SetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue: Integer);
Restrictions
164
SetRGBPalette can be used only with the IBM 8514 driver and the VGA.
See also
Example
Programmer's Reference
SetRGBPalette procedure
Example 1:
uses Graph;
type
RGBRec = record
RedVal, GreenVal, BlueVal: Integer;
end;
const
EGAColors: array[O .. MaxColors] of RGBRec =
(
{NAME
(RedVal:$OO;GreenVal:$OO;BlueVal:$OO) ,{Black
(RedVal:$OO;GreenVal:$OO;BlueVal:$FC) ,{Blue
(RedVal:$24;GreenVal:$FC;BlueVal:$24) ,{Green
(RedVal:$OO;GreenVal:$FC;BlueVal:$FC) ,{Cyan
(RedVal:$FC;GreenVal:$14;BlueVal:$14) ,{Red
(RedVal:$BO;GreenVal:$OO;BlueVal:$FC) ,{Magenta
(RedVal:$70;GreenVal:$48;BlueVal:$00) ,{Brown
(RedVal:$C4;GreenVal:$C4;BlueVal:$C4) ,{White
(RedVal:$34;GreenVal:$34;BlueVal:$34) ,{Gray
(RedVal:$00;GreenVal:$00;BlueVal:$70},{Lt Blue
(RedVal:$00;GreenVal:$70;BlueVal:$00},{Lt Green
(RedVal:$00;GreenVal:$70;BlueVal:$70},{Lt Cyan
(RedVal:$70;GreenVal:$00;BlueVal:$00},{Lt Red
(RedVal:$70;GreenVal:$00;BlueVal:$70},{Lt Magenta
(RedVal:$FC;GreenVal:$FC;BlueVal:$24) , {Yellow
(RedVal;$FC;GreenVal:$FC;BlueVal:$FC) {Br. White
COLOR}
EGA O}
EGA 1}
EGA 2}
EGA 3}
EGA 4}
EGA 5}
EGA 20}
EGA 7}
EGA 56}
EGA 57}
EGA 58}
EGA 59}
EGA 60}
EGA 61}
EGA 62}
EGA 63}
};
var
Driver, Mode, I: Integer;
begin
Driver := IBM8514;
Mode := IBM8514Hi;
InitGraph(Driver, Mode, "};
if GraphResult < 0 then
Halt(l} ;
{ Zero palette, make all graphics output invisible
for I := 0 to MaxColors do
with EGAColors[I] do
SetRGBPalette(I, 0, 0, O};
{ Display something }
{ Change first 16 8514 palette entries
for I := 1 to MaxColors do
begin
SetColor(I} ;
OutTextXY(lO, I * 10, ' .. Press any key .. '};
end;
{ Override detection
Put in graphics mode
165
SetRGBPaleHe procedure
Example 2:
{ Example for SetRGBPalette with VGA 16 color modes }
uses Graph, CRTi
type
RGBRec = record
RedVal, GreenVal, BlueVal : Integeri
{ Intensity values (values from 0 to 63) }
Name: Stringi
ColorNum: Integeri
{ The VGA color palette number as mapped into 16 color palette }
endi
const
{ Table of suggested colors forVGA 16 color modes }
Colors : array[O . . MaxColors] of RGBRec = (
( RedVal:OiGreenVal:OiBlueVal:OiName:'Black'iColorNum: 0),
( RedVal:OiGreenVal:OiBlueVal:40iName:'Blue'iColorNum: 1),
( RedVal:OiGreenVal:40iBlueVal:OiName:'Green' iColorNum: 2),
( RedVal:OiGreenVal:40iBlueVal:40iName:'Cyan' iColorNum: 3),
( RedVal:40iGreenVal:7iBlueVal:7iName: 'Red' iColorNum: 4),
( RedVal:40iGreenVal:OiBlueVal:40iName:'Magenta'iColorNum: 5),
( RedVal:40iGreenVal:30i BlueVal:OiName: 'Brown' iColorNum: 20),
( RedVal:49iGreenVal:49iBlueVal:49iName: 'Light Gray'iColorNum: 7),
( RedVal:26iGreenVal:26iBlueVal:26iName: 'Dark Gray'iColorNum: 56),
( RedVal:OiGreenVal:OiBlueVal:63iName:'Light Blue'iColorNum: 57),
( RedVal:9iGreenVal:63iBlueVal:9iName:'Light Green'iColorNum: 58),
( RedVal:OiGreenVal:63iBlueVal:63iName:'Light Cyan'iColorNum: 59),
( RedVal:63iGreenVal:10iBlueVal:10iName:'Light Red'iColorNum: 60),
( RedVal:44iGreenVal:OiBlueVal:63iName:'Light Magenta'i
ColorNum:61) ,
( RedVal:63iGreenVal:63iBlueVal:18iName:'Yellow'iColorNum: 62),
( RedVal:63i GreenVal:63i BlueVal:63i Name: 'White'i ColorNum: 63)
)i
var
Driver, Mode, I, Error: Integeri
begin
{ Initialize Graphics Mode
Driver := VGAi
Mode := VGAHii
166
Programmer's Reference
SetRGBPaleHe procedure
Bar(10, (I + 2) * 10 - 1, 10 + TextWidth(Name) ,
(I + 2) * 10 + TextHeight(Name) - 1);
OutTextXY(10, (I + 2) * 10, Name);
end;
end;
ReadKey;
{ Restore original colors to the palette. The default colors might vary
depending upon the initial values used by your video system.}
for i := 0 to 15 do
with Colors[i] do
SetRGBPalette(ColorNum, RedVal, GreenVal, BlueVal);
{ Wait for a keypress and then quit graphics and end. }
ReadKey;
Closegraphi
end.
167
SetTextBuf procedure
SetTextBuf procedure
Purpose
Declaration
Remarks
System
SctTextBuf changes the text file F to use the buffer specified by Buf instead
of F's internal buffer. Size specifies the size of the buffer in bytes. If Size is .
omitted, SizeOf(Buj) is assumed; that is, by default, the entire memory
region occupied by Buf is used as a buffer. The new buffer remains in
effect until F is next passed to Assign.
Restrictions
Example
var
F: Text;
Ch: Char;
Buf: array [ 0.. 4095] of Char;
{ 4K buffer }
begin
168
Programmer's Reference
SetTextJustify procedure
SetTextJustify procedure
Purpose
Declaration
Remarks
Graph
The point (100, 100) will appear in the middle of the letter B. The default
justification settings can be restored by setTextfustify(LeftText, TopText). If
invalid input is passed to setTextfustify, GraphResult returns a value of
grError, and the current text justification settings will be unchanged. See
page 99 for a list of Justification constants.
Restrictions
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
{ Center text onscreen }
SetTextJustify(CenterText, CenterText);
OutTextXY(Succ(GetMaxX) div 2, Succ(GetMaxY) div 2, 'Easily Centered');
Readln;
CloseGraph;
end.
SetTextStyle procedure
Purpose
Declaration
Remar.ks
Graph
Sets the current text font, style, and character magnification factor.
procedure SetTextStyle(Font: Word; Direction: Word; CharSize: Word);
Affects all text output by OutText and OutTextXY. One 8x8 bit-mapped
font and several stroked fonts are available. Font directions supported
are normal (left to right) and vertical (90 degrees to normal text, starts at
the bottom and goes up). The size of each character can be magnified
using the Char Size factor. A Charsize value of one will display the 8x8 bit-
169
SetTextStyle procedure
grlnvalidFontNum.
Restrictions
170
See also
Example
uses Graph;
var
Gd,Gm: Integer;
Y, Size: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, II);
if GraphResult <> grOk then
Halt (1) ;
Y := 0;
for Size := 1 to 4 do
begin
SetTextStyle(DefaultFont, HorizDir, Size);
OutTextXY(O, Y, 'Size = ' + Chr(Size + 48));
Inc(Y, TextHeight('H') + 1);
end;
Readln;
CloseGraphi
end.
Programmer's Reference
SetTime procedure
SetTime" procedure
Purpose
Declaration
Dos, WinDos
Remarks
Valid ranges are Hour 0.. 23, Minute 0..59, Second 0..59, and Sec100
(hundredths of seconds) 0.. 99. If the time isn't valid, the request is ignored.
See also
SetUserCharSize procedure
Purpose
Declaration
Remarks
Restrictions
Graph
Allows the user to vary the character width and height for stroked fonts.
procedure SetuserCharSize(MultX, Divx, MultY, DivY: Word;)
MultX:DivX is the ratio multiplied by the normal width for the active font;
MultY:DivY is the ratio multiplied by the normal height for the active font.
In order to make text twice as wide, for example, use a MultX value of 2,
and set DivX equal to 1 (2 div 1 = 2). Calling SetUserCharSize sets the
current character size to the specified values.
Must be in graphics mode.
See also
Example
The following program shows how to change the height and width of text:
uses Graph;
var Driver, Mode: Integer;
begin
Driver := Detect;
InitGraph(Driver, Mode, ");
if GraphResult <> grOk then
Halt (1) ;
{ Showoff }
SetTextStyle(TriplexFont, HorizDir, 4);
OutText ('Norm') ;
SetUserCharSize(l, 3, 1, 1);
OutText('Short ');
SetUserCharSize(3, 1, 1, 1);
OutText ('Wide');
Readln;
CloseGraph;
end.
171
SetVerify procedure
Dos, WinDos
SetVerify procedure
Purpose
Declaration
Remarks
Set Verify sets the state of the verify flag in DOS. When off (False), disk
writes are not verified. When on (True), DOS verifies all disk writes to
ensure proper writing.
See also
Get Verify
.SetViewPort procedure
Purpose
Declaration
Remarks
Graph
(Xl, Yl) define the upper left corner of the viewport, and (X2, Y2) define
the lower right corner (0 <= Xl < X2and 0 <= Yl < Y2). The upper left
corner of a viewport is (0,0).
The Boolean parameter Clip determines whether drawings are clipped at
the current viewport boundaries. setViewPort(O, 0, GetMaxX, GetMaxY,
True) always sets the viewport to the entire graphics screen. If invalid
input is passed to Set ViewPort, GraphResult returns grError, and the
current view settings will be unchanged.
All graphics commands (for example, GetX, OutText, Rectangle, MoveTo,
and so on) are viewport-relative. In the following example, the
coordinates of the dot in the middle are relative to the boundaries of the
viewport.
(0,0)
(GetMaxX,O)
(X1,Y1)
(X2,Y1)
(X1,Y2)
(O,GetMaxY)
(X2,Y2)
(GetMaxX,GetMaxY)
172
Programmer's Reference
SetViewPort procedure
"current pointer" is never clipped. The following will not draw the
complete line requested because the line will be clipped to the current
viewport:
SetViewPort(10, 10, 20, 20, ClipOn);
Line(O, 5, 15, 5);
See also
Example
uses Graph;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
if (Gd = HercMono) or (Gd = EGA) or (Gd
begin
SetVisualPage(O);
SetActivePa~e(l) ;
Rectangle(10, 20, 30, 40) i
SetvisualPage(l);
end
else
OutText('No paging supported.');
Readlni
CloseGraph;
end.
SetVisualPage procedure
Purpose
Declaration
= EGA64)
or (Gd
= VGA)
then
I
Graph
173
SefVisualPage procedure
Remarks
Restrictions
See also
SetActivePage
Example
uses Graph;
var Gd,Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, If);
if GraphResult <> grOk then
Halt(l) ;
if (Gd = HercMono) or (Gd = EGA) or (Gd
begin
SetVisualPage(O);
SetActivePage(l);
Rectangle (10, 20, 30, 40);
SetVisualPage(l);
end
else
OutText('No paging supported.');
Readln;
CloseGraph;
end.
SetWriteMode procedure
Purpose
Declaration
Remarks
174
Graph
Programmer's Reference
SetWriteMode procedure
Example
Halt (1) ;
Sin function
Purpose
Declaration
,System
Returns the sine of the argument.
function Sin (X: Real): Real;
Remarks
See also
ArcTan, Cos
175
Example
var R: Real i
begin
R := Sin(pi)
end.
System
SizeOf function
Purpose
Declaration
RSmarks
Example
type
CustRec = record
Name: string[30]i
phone: string[14] i
endi
var P: ACustReci
begin
GetMem(P, SizeOf(CustRec))i
end.
Crt
Sound procedure
Purpose
Declaration
176
Remarks
See also
NoSound
Example
uses Crt i
begin
Sound (220) i
Delay(200) i
NoSoundi
end.
Programmer's Reference
SPtr function
SPtr function
Purpose
Declaration
System
Returns the current value of the SP register.
function SPtr: Word;
Remarks
Returns the offset of the stack pointer within the stack segment.
See also
SSeg
Sqr function
Purpose
Declaration
Result type
Remarks
System
Returns the square of the argument.
function Sqr (Xl;
Sqrt function
Purpose
Declaration
Remarks
System
Returns the square root of the argument.
function Sqrt (X: Real l: Real;
SSeg function
Purpose
Declaration
System
Remarks
The result, of type Word, is the segment address of the stack segment.
See also
StackLimit variable
Purpose
Declaration
System
Contains the offset of the bottom of the stack in the stack segment.
var StackLimit: Word;
177
StackLimit variable
Remarks
StackLimit returns the lowest value the SP register can contain before it is
considered a stack overflow.
See also
SPtr
Str procedure
Purpose
Declaration
System
Converts a numeric value to its string representation.
procedure Str (X [: Width [: Decimals ] ]; var S);
Remarks
See also
Val, Write
Example
Streat function
Purpose
Declaration
178
Strings
Appends a copy of one string to the end of another and returns the
concatenated string.
function StrCat (Dest, Source: PChar): PChar;
Remarks
StrCat appends a copy of Source to Dest and returns Dest. StrCat does not
perform any length checking. You must ensure that the buffer given by
Dest has room for at least StrLen(Dest) + StrLen(Source) + 1 characters. If
you want length checking, use the StrLCat function.
See also
StrLCat
Programmer's Reference
Streat function
Example
uses Strings;
const
Turbo: PChar = 'Turbo';
Pascal: PChar = 'Pascal';
var
S: array[O .. 15] of Char;
begin
StrCopy(S, Turbo);
StrCat(S, ' ');
StrCat(S, Pascal);
Writeln(S) ;
end.
StrComp function
Purpose
Declaration
Remarks
See also
Example
uses Strings;
var
C: Integer;
Result: PChar;
Sl, S2: array[O .. 79] of Char;
begin
Readln(Sl) ;
Readln(S2) ;
C := StrComp(Sl, S2);
if C < 0 then Result := ' is less than ' else
if C > 0 then Result := ' is greater than' else
Result := 'is equal to ';
Writeln(Sl, Result, S2);
end.
StrCopy function
Purpose
Declaration
Strings
I
Strings
t'
179
5trCopy function
Remarks
StrCopy copies Source to Dest and returns Dest. StrCopy does not perform
any length checking. You must ensure that the buffer given by Dest has
room for at least StrLen(Source) + 1 characters. If you want length
checking, use the StrLCopy fUhction.
See also
StrECopy, StrLCopy
Example
uses Strings;
var
S: array [0 .. 15) of. Char;
begin
StrCopy(S, 'Turbo Pascal');
Writeln (S) ;
end.
StrDispose function
Purpose
Declaration
Strings
Remarks
See also
StrNew
StrECopy function
Purpose
Declaration
180
Strings
Remarks
StrECopy copies Source to Dest and returns StrEnd(Dest). You must ensure
that the buffer given by Dest has room for at least StrLen(Source) + 1
characters. Nested calls to StrECopy can be used to concatenate a sequence
of strings-this is illustrated by the example that follows.
See also
StrCopy, StrEnd
Example
uses Strings;
const
Turbo: PChar = 'Turbo';
Pascal: PChar = 'Pascal';
var
S: array[O .. 15) of Char;
Programmer's Reference
5trECopy function
begin
StrECopy(StrECopy(StrECopy(S, Turbo), ' '), Pascal);
Writeln(S) ;
end.
StrEnd function
Purpose
Declaration
Strings
Remarks
See also
Str Len
Example
uses Strings;
var
S: array[O .. 79] of Char;
begin
Readln(S);
Writeln('String length is'
end.
StrEnd(S) - S);
StrlComp function
Purpose
Declaration
Strings
Remarks
StrIComp compares Strl to Str2 without case sensitivity. The return value
is the same as StrComp.
See also
StrLCat function
Purpose
Declaration
Strings
Appends characters from a string to the end of another, and returns the
concatenated string.
function StrLCat (Dest, Source: PChar; MaxLen: Word): PChar;
181
StrLCat function
Remarks
See also
StrCat
Example
uses Strings;
var
S: array[O .. 9] of Char;
begin
StrLCopy(S, 'Turbo', SizeOf(S) - 1)
StrLCat(S, ' " SizeOf(S) - 1);
StrLCat(S, 'Pascal', SizeOf(S) - 1);
Writeln(S) ;
end.
StrLComp function
Purpose
Declaration
Strings
Remarks
'See also
Example
uses Strings;
var
Result: PChar;
Sl, S2: array[O .. 79] of Char;
begin
Readln(Sl);
Readln (S2 ) ;
if StrLComp(Sl, S2, 5) = 0 then
Result .- 'equal'
else
Result .- 'different';
Writeln('The first five characters are'
end.
Result);
StrLCopy function
Purpose
Declaration
182
Strings
Programmer's Reference
StrLCopy function
Remarks
StrLCopy copies at most MaxLen characters from Source to Dest and returns
Dest. The SizeO! standard function can be used to determine the MaxLen
parameter-this is demonstrated by the example that follows.
See also
StrCopy
Example
uses Strings;
var
S: array[O .. 9] of Char;
begin
StrLCopy(S, 'Turbo Pascal', SizeOf(S) - 1);
Writeln(S) ;
end.
StrLen function
Purpose
Declaration
Strings
Remarks
StrLen returns the number of characters in Str, not counting the null
terminator.
See also
StrEnd
Example
uses Strings;
var
S: array[O .. 79] of Char;
begin
Readln(S) ;
Writeln('St:dng length is'
end.
StrLen(S));
_St_rL_I_C_o_m~p__fu_n_c_t_io_n____________________________~____St_r_in_g_s
Purpose
Declaration
Remarks
See also
183
III
5trLower function
Strings
StrLower function
Purpose
Declaration
Remarks
See also
StrUpper
Example
uses Strings;
var
S: array[0 .. 79] of Char;
begin
Readln(S);
Writeln(StrLower(S));
Writeln(StrUpper(S));
end.
StrMove function
Purpose
Declaration
184
Strings
Remarks
StrMove copies exactly Count characters from Source to Dest and returns
Dest. Source and Dest can overlap.
Example
Programmer's Reference
StrNew function
StrNew function
Purpose
Declaration
Strings
Remarks
See also
StrDispose
Example
uses Strings;
var
P: PChar;
S: array[O .. 79] of Char;
begin
Readln(S) ;
P : = StrNew(S);
Writeln (P) ;
StrDispose(P);
end.
StrPas function
Purpose
Declaration
Strings
Remarks
See also
StrPCopy
Example
uses Strings;
var
A: array[O .. 79] of Char;
S: string [79] ;
begin
Readln (A) ;
S : = StrPas (A); _
Writeln(S);
end.
185
StrPCopy function
StrPCopy function
Purpose
Declaration
Strings
PChari
Source: String):
PChari
Remarks . StrPCopy copies the Pascal-style string Source into Dest and returns Dest.
You must ensure that the buffer given by Dest has room for at least
. Length(Source) + 1 characters.
See also
StrCopy
Example
uses Strings i
var
A: array[O .. 79] of
S: string[79] i
begin
Readln(S) i
StrPCopy(A, S) i
Writeln (A) i
end.
Chari
StrPos function
Purpose
Declaration
186
Strings
PChari
Remarks
StrPos rehlrns a pointer to the first occurrence of Str2 in Strl. If Str2 does
not occur in Strl, StrPos returns nil.
Example
uses Strings i
var
P: PChari
S, SubStr: array[O .. 79] of Chari
begin
Readln(S)i
Readln(SubStr)i
P := StrPos(S, SubStr)i
if P = nil then
Writeln('Substring not found')i
else
Writeln('Substring found at index', P - S)i
end.
Programmer's Reference
StrRScan function
StrRScan function
Purpose
Declaration
Strings
Remarks
StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr does
not occur in Str, StrRScan returns nil. The null terminator is considered to
be part of the string.
See also
StrScan
Example
StrScan function
Purpose
Declaration
Strings
Remarks
StrScan returns a pointer to the first occurrence of Chr in Str.1f Chr does
not occur in Str, StrScan returns nil. The null terminator is considered to
be part of the string.
See also
StrRScan
Example
187
5trUpper function
Strings
StrUpper function
Purpose
Declaration
Remarks
uses Strings i
var
S: array[O .. 79] of Chari
begin
Readln(S) i
Writeln(StrUpper(S)) i
Writeln(StrLower(S))i
end.
Succ function
Purpose
Declaration
Result type
System
Returns the successor of the argument.
function
Succ (X) :
Remarks
See also
Swap function
Purpose
Declaration
Result type
188
System
Swaps the high- and low-order bytes of the argument.
function Swap (X) i
Remarks
See also
Hi, La
Programmer's Reference
Swap function
Example
var x: Word;
begin
X := Swap($1234);
end.
{$3412}
SwapVectors procedure
Purpose
Declaration
Dos
Remarks
Swaps the contents of the SaveIntXX pointers in the System unit with the
current contents of the interrupt vectors. Swap Vectors is typically called
just before and just after a call to Exec. This ensures that the Execed
process does not use any interrupt handlers installed by the current
process and vice versa.
See also
Exec, SavelntXX
Example
{$M 8192,O,O}
uses Dos;
var Command: string[79];
begin
Write('Enter DOS command: ~);
Readln(Command) ;
if Command <> " then
Command:= 'IC ' + Command;
SwapVectors;
Exec (GetEnv('COMSPEC'), Command);
SwapVectors;
if DosError <> 0 then
Writeln( 'Could not execute COMMAND. COM' );
end.
TDateTime type
Purpose
Declaration
WinDos
189
TOateTime type
Remarks
Valid ranges are Year 1980 ..2099, Month 1..12, Day 1..31, Hour 0.. 23, Min
0 ..59, and Sec 0..59.
See also
PackTime
System
Test8086 variable
Purpose
Declaration
Remarks
The run-time library's start-up code contains detection logic that automatically determines what kind of 80x86 processor the system contains.
The result of the CPU detection is stored in TestSOS6 as one of the
following values:
Value
o
1
2
Definition
Processor is an 8086
Processor is an 80286
Processor is an 80386 or later
When the run-time library detects that the processor is an 80386 or later
CPU, it uses 80386 instructions to speed up certain operations. In
particular, Longint multiplication, division, and shifts are performed using
32-bit instructions when an 80386 is detected.
See also
TestSOS7
System
Test808? variable
Purpose
Declaration
Remarks
o
1
2
3
190
Definition
No coprocessor detected
8087 detected
80287 detected
80387 or later detected
Programmer's Refer?nce
Test8087 variable
X := 0;
case
0:
1:
2:
3:
end;
end.
TextAttr variable
Purpose
Declaration
Remarks
Crt
Although text attributes are normally set through calls to TextColor and
TextBackground, you can also set them by directly storing a value in
TextAttr. The color information is encoded in TextAttr as follows:
bit -
7 6 5 4 3 2 1 0
Islblblblflflflfl
where ffff is the 4-bit foreground color, bbbb is the 3-bit background color,
and B is the blink-enable bit. If you use the color constants for creating
TextAttr values, the background color can only be selected from the first 8
colors, and it must be multiplied by 16 to get it into the correct bit
positions. For example, the following assignment selects blinking yellow
characters on a blue background:
TextAttr := Yellow + Blue * 16 + Blink;
See also
191
Crt
Purpose
Remarks
The following constants are used in connection with the T ext Color and
TextBackground procedures.
Constant
Black
Blue
Green
Cyan
Red
. Magenta
Brown
LightGray
DarkGray
LightBlue
LightGreen'
LightCyan
LightRed
LightMagenta
Yellow
White
Blink
Value
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
128
Text colors are represented by the numbers between 0 and 15; to easily
identify each color, you can use these constants instead of numbers. In the
color text modes, the foreground of each character is selectable from 16
colors, and the background from 8 colors. The foreground of each
character can also be made to blink.
See also
TextBackground procedure
Purpose
Declaration
Remarks
192
Crt
Programmer's Reference
TextBackground procedure
TextColor procedure
Purpose
Declaration
Remarks
Crt
See also
Example
TextColor (Green);
TextColor(LightRed + Blink);
TextColor(14) ;
TextHeight function
Purpose
Declaration
Remarks
{ Green characters
{ Blinking light-red characters }
{ Yellow characters }
Graph
Takes the current font size and multiplication factor, and determines the
height of TextString in pixels. This is useful for adjusting the spacing
between lines, computing viewport heights, sizing a title to make it fit on
a graph or in a box, and more.
For example, with the 8x8 bit-mapped font and a multiplication factor of 1
(set by SetTextStyle), the string Turbo is 8 pixels high.
It is important to use TextHeight to compute the height of strings, instead
of doing the computation manually. In that way, no source code modifications have to be made when different fonts are selected.
193
II
TextHeight function
Restrictions
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Y, Size: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1);
Y := 0;
for Size := 1 to 5 do
begin
SetTextStyle(DefaultFont, HorizDir, Size);
OutTextXY(O, Y, 'Turbo Graphics');
Inc(Y, TextHeight('Turbo Graphics'));
end;
Readln;
CloseGraph;
end.
TextMode procedure
Purpose
Declaration
Remarks
Crt
See page 25 for a list of defined Crt mode constants. When TextMode is
called, the current window is. reset to the entire screen, DirectVideo is set to
True, CheckS now is set to True if a color mode was selected, the current text
attribute is reset to normal corresponding to a call to NormVideo, and the
current video is stored in LastMode. In addition, LastMode is initialized at
program startup to the then-active video mode.
Specifying TextMode(LastMode) causes the last active text mode to be
reselected. This is useful when you want to return to text mode after using
a graphics package, such as Graph or Graph3.
The following call to TextMode:
TextMode(C80 + Font8x8)
will reset the display into f-l3lines and 80 columns on an EGA, or 50 lines
and 80 columns on a VGA' with a color monitor. TextMode(Lo(LastMode))
194
Programmer's Reference
TextMode procedure
always turns off 43- or 50-line mode and resets the display (although it
leaves the video mode unchanged); while
TextMode (Lo (LastMode) + Font8x8)
will keep the video mode the same, but reset the display into 43 or 50
lines.
If your system is in 43- or 50-line mode when you load a Turbo Pascal
program, the mode will be preserved by the Crt startup code, and the
window variable that keeps track of the maximum number of lines
onscreen (WindMax) will be initialized correctly.
Here's how to write a "well-behaved" program that will restore the video
mode to its original state:
program Video;
uses Crt;
var OrigMode: Integer;
begin
OrigMode := LastMode;
TextMode(OrigMode) ;
end.
Note that TextMode does not support graphics modes, and therefore
TextMode(OrigMode) will only restore those modes supported by
TextMode.
See also
TextRec.type
Purpose
Declaration
Dos
Record definition used internally by Turbo Pascal and also declared in the
Dos unit.
type
TextBuf = array[O .. 127J of Char;
TextRec = record
Handle: Word;
Mode: Word;
BufSize: Word;
Private: Word;
BufPos: Word;
BufEnd: Word;
BufPtr: ATextBuf;
OpenFunc: Pointer;
InOutFunc: Pointer;
195
TextRec type
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[l .. 16] of Byte;
Name: array[O .. 79] of Char;
Buffer: TextBuf;
end;
Remarks
TextRec is the internal format of a variable of type Text. See Chapter 18,
"Using overlays," in the Language Guide for additional information.
See also
FileRec
TextSettingsType type
Purpose
Declaration
Graph
TextSettingsType = record
Font: Word;
Direction: Word;
CharSize: Word;
Horiz: Word;
Vert: Word;
end; .
Remarks
See page 55 for a list of the Font control control constants used to identify
font attributes.
TextWidth function
Purpose
Declaration
Remarks
Graph
Takes the string length, current font size, and multiplication factor, and
determines the width of TextString in pixels. This is useful for computing
viewport widths, sizing a title to make it fit on a graph or in a box, and so
on.
For example, with the 8x8 bit-mapped font and a multiplication factor of 1
(set by SetTextStyle), the string Turbo is 40 pixels wide.
It is important to use TextWidth to compute the width of strings, instead of
doing the computation manually. In that way, no source code
modifications have to be made when different fonts are selected.
Restrictions
196
Programmer's Reference
TextWidth function
See also
Example
uses Graph;
var
Gd, Gm: Integer;
Row: Integer;
Title: String;
Size: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ");
if GraphResult <> grOk then
Halt (1) ;
Row := 0;
Title := 'Turbo Graphics';
Size := 1;
while TextWidth(Title) < GetMaxX do
begin
OutTextXY(O, Row, Title);
Inc (Row, TextHeight('M'));
Inc(Size);
SetTextStyle(DefaultFont, HorizDir, Size);
end;
Readln;
CloseGraph;
'end.
TFileRec type
Purpose
Declaration
Remarks
WinDos
A record definition used f~r both typed and untyped files.
type
TFileRec = record
Handle: Word;
Mode: Word;
RecSize: Word;
Private: array[1 .. 26] of Byte;
UserData: array[1 .. 16] of Byte;
Name: array[O .. 79] of Char;
end;
197
TRegisters type
WinDos
TRegisters type
Purpose
Declaration
Notice the use of a variant record to map the 8-bit registers on top of their
16-bit equivalents.
Trunc function
Purpose
Declaration
Remarks
Restrictions
See also
System
Truncates a real-type value to an integer-type value.
function Trunc (X: Real): Longint;
Round, Int
System
Truncate procedure
Purpose
Declaration
Remarks
F is a file variable of any type. All records past F are deleted, and the
current file position also becomes end-of-file (Eof(F) is True).
If I/O-checking is off, the IOResult function returns a nonzero value if an
error occurs.
Restrictions
See also
198
Programmer's Reference
TSearchRec type
TSearchRec type
Purpose
Declaration
WinDos
TSearchRec = record
Fill: array[1 .. 21] of Byte;
Attr: Byte;
Time: Longint;
Size: Longint;
Name: array[O .. 12] of Char;
end;
Remarks
The information for each file found by one of these procedures is reported
back in a TSearchRec. The Attr field contains the file's attributes
(constructed from file attribute constants), Time contains its packed date
and time (use UnpackTime to unpack), Size contains its size in bytes, and
Name contains its name. The Fill field is reserved by DOS; don't modify it.
See also
FindFirst, FindNext
TIextRec type
Purpose
Declaration
WinDos
A record definition that is the internal format of a variable of type Text.
type
PTextBuf = ATTextBuf;
TTextBuf = array[O .. 127] of Char;
TTextRec = record
Handle: Word;
Mode: Word;
BufSize: Word;
Private: Word;
BufPos: Word;
BufEnd: Word;
BufPtr: PTextBuf;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1 .. 16] of Byte;
Name: array[O .. 79] of Char;
Buffer: TTextBuf;
end;
I
199
TTextRec type
Remarks
TypeOf function
Purpose
Declaration
Remarks
UnpackTime procedure
Purpose
Declaration
Dos, WinDos
Remarks
DateTime is a record declared in the Dos unit. If you are writing Windows
programs, use TDateTime. The fields of the Time record are not rangechecked. See page 26 for the DateTime record declaration and page 189 for
the TDateTime r~cord declaration.
See also
UpCase function
Purpose
Declaration
Remarks
200
System
System
Programmer's Reference
Val procedure
System
Val procedure
Purpose
Declaration
Remarks
:=
LongIntVari
In this example, LongIntVar would be set to 65,536, and Code would equal
O. Because 65,536 is out of range for a Word variable, an error would be
reported.
Restrictions
See also
Str
201
Val procedure
Example
ViewPortType type
Purpose
Declaration
Graph
Remarks
The points (Xl, Yl) and (X2, Y2) are the dimensions of the active viewport
and are given in absolute screen coordinates. Clip is a Boolean variable
that controls whether clipping is active.
See also
GetViewSettings
WhereX function
Purpose
Declaration
See also
Crt
WhereY function
Purpose
Declaration
See also
202
Crt
Programmer's Reference
Crt
Remarks
These variables are set by calls to the Window procedure. WindMin defines
the upper left corner, and WindMax defines the lower right corner. The
x-coordinate is stored in the low byte, and the y-coordinate is stored in the
high byte. For example, Lo(WindMin) produces the x-coordinate of the left
edge, and Hi(WindMax) produces the y-coordinate of the bottom edge.
The upper left corner of the screen corresponds to (x,y) = (0,0). However,
for coordinates passed to Window and GotoXY, the upper left corner is at
(1,1).
See also
Window procedure
Purpose
Declaration
Remarks
Crt
Xl and Yl are the coordinates of the upper left corner of the window, and
X2 and Y2 are the coordinates of the lower right corner. The upper left
corner of the screen corresponds to (1, 1). The minimum size of a text
window is one column by one line. If the coordinates are in any way
invalid, the call to Window is ignored.
.
The default window is (1, 1,80,25) in 25-line mode, and (1, 1,80,43) in
43-linemode, corresponding to the entire screen.
All screen coordinates (except the window coordinates themselves) are
relative to the current window. For instance, GotoXY(1, 1) will always
position the cursor in the upper left corner of the current window.
Many Crt procedures and functions are window-relative, including ClrEol,
ClrSer, DelLine, GotoXY, InsLine, WhereX, WhereY, Read, Readln, Write,
Writeln.
WindMin and WindMax store the current window definition. A call to the
Window procedure always moves the cursor to (1, 1).
See also
203
Window procedure
Example
uses Crt;
var
X, Y: Byte;
begin
TextBackground(Black);
ClrScr;
repeat
X := Succ(Random(80));
Y := Succ(Random(25));
Window (X, Y, X + Random(lO)
TextBackground(Random(16));
ClrScr;
until KeYPressed;
end.
{ Clear screen }
Y + Random(8));
{ In random colors }
System
P2/ "P N
1 );
where OutExpr is an output expression. Min Width and DecPlaces are type
integer expressions.
Min Width specifies the minimum field width, which must be greater than
O. Exactly Min Width characters are written (using leading blanks if necessary) except when OutExpr has a value that must be represented in more
than Min Width characters. In that case, enough characters are written to
represent the value of OutExpr. Likewise, if MinWidth is omitted, then the
necessary number of characters are written to represent the value of
OutExpr.
DecPlaces specifies the number of decimal places in a fixed-point representation of a type Real value. It can be specified only if OutExpr is of type
204
Programmer's Reference
Real, and if Min Width is also specified. When Min Width is specified, it
must be greater than or equal to O.
Write with a character-type value: If MinWidth is omitted, the character
value of OutExpr is written to the file. Otherwise, Min Width - 1 blanks
followed by the character value of OutExpr is written.
Write with a type integer value: If Min Width is omitted, the decimal
representation of OutExpr is written to the file with no preceding blanks.
If Min Width is specified and its value is larger than the length of the
decimal string, enough blanks are written before the decimal string to
make the field width Min Width.
Write with a type real value: If OutExpr has a type real value, its decimal
[ I -]
<digit>
<decimals>
[+ I- ]
<exponent>
string follows:
[ <blanks> 1 [ - 1 <digits> [ . <decimals> 1
[ <blanks> ]
[- ]
If OutExpr is negative
<digits>
[ . <decimals> ]
I
205
Write with a string-type value: If Min Width is omitted, the string value of
System
/ VN
1 )i
See also
Writeln
System
Writeln procedure
Purpose
Declaration
Remarks
206
/ PN
1 )i
Programmer's Reference
WrlTeln proceaure
I
Chapter 7, Library reference
207
208
Programmer's Reference
2
Compiler directives
See Appendix B for a table
summarizing the compiler
directives.
209
You can put compiler directives directly into your source code.
You can also change the default directives for both the
command-line compiler (TPC.EXE) and the IDE (TURBO.EXE or
TPX.EXE). The Options I Compiler menu contains many of the
compiler directives; any changes you make to the settings there
will affect all subsequent compilations.
When using the command-line compiler, you can specify compiler
directives on the command line (for example, TPC I$R+ MYPROG), or
you can place directives in a configuration file (see Chapter 3).
Compiier directives in the source code always override the
default values in both the command-line compiler and the IDE.
If you are working in the IDE, using the editor's Alternate
command set, and want a quick way to see what compiler
directives are in effect, press Ctr/+O O. Turbo Pascal will insert the
current settings at the top of your edit window.
210
.Programmer's Reference
Align data
Align data
Switch
Syntax
{$A+}
Default
{$A+}
Type
Remarks
or
{$A-}
Global
The $A directive switches between byte and word alignment of variables
and typed constants. Word alignment has no effect on the 8088 CPU.
However, on a1l80x86 CPUs, word alignment means faster execution
because word-sized items on even addresses are accessed in one memory
cycle rather than two memory cycles for words on odd addresses.
In the {$A+} state, all variables and typed constants larger than one byte
are aligned on a machine-word boundary (an even-numbered address). If
required, unused bytes are inserted between variables to achieve word
alignment. The {$A+} directive does not affect byte-sized variables, nor
does it affect fields of record structures and elements of arrays. A field in a
rec01;:d will align on a word boundary only if the total size of all fields
before it is even. For every element of an array to align on a word
boundary, the size of the elements must be even.
In the {$A-} state, no alignment measures are taken. Variables and typed
constants are simply placed at the next,available address, regardless of
their size.
Regardless of the state of the $A directive, each global var and const
declaration section always starts at a word boundary. Likewise, the
compiler always keeps the stack pointer (SP) word aligned by allocating
an extra unus~d byte in a procedure'S stack frame if required.
Boolean evaluation
Syntax
{$B+}
Default
{$B- }
Type
Remarks
or
Switch
{$B-}
Local
The $B directive switches between the two different models of code
generation for the and and or Boolean operators.
In the {$B+} state, the compiler generates code for complete Boolean
expression evaluation. This means that every operand of a Boolean
expression built from the and and or operators is guaranteed to be
evaluated, even when the result of the entire expression is already known.
211
Boolean evaluation
In the {$B-} state, the compiler generates code for short-circuit Boolean
expression evaluation, which means that evaluation stops as soon as the
result of the entire expression becomes evident.
For further details, see the section "Boolean operators" in Chapter 6,
"Expressions," in the Language Guide.
Debug information
Syntax
{ $D+} or {$D-}
Default
{$D+ }
Type
Remarks
Switch
Global
The $0 directive enables or disables the generation of debug information.
This information consists of a line-number table for each procedt:Lre,
which maps object code addresses into source text line numbers.
For units, the debug information is recorded in the .TPU file along with
the unit's object code. Debug information increases the size of .TPU files
and takes up additional room when compiling programs that use the unit,
but it does not affect the size or speed of the executable program.
When a program or unit is compiled in the {$O+} state, Turbo Pascal's
integrated debugger lets you single-step and set breakpoints in that
module.
The Standalone debugging (Options I Debugger) and Map file (Options I
Linker) options produce complete line information for a given module
only if you've compiled that module in the {$O+} state.
The $0 switch is usually used in conjunction with the $L switch, which
enables and disables the generation of local symbol information for '
debugging.
.
If you want to use Turbo Debugger to debug your program, set Compile I
Destination to Disk, choose Options I Debugger, and select the Standalone
option.
DEFINE directive
Syntax
Remarks
212
Conditional compilation
{$DEFINE name}
Programmer's Reference
ELSE directive
ELSE directive
Syntax
Remarks
Conditional compilation
{$ELSE}
Switches between compiling and ignoring the source text delimited by the
last {$IFxxx} and the next {$ENDIF}.
Emulation
Switch
Syntax
{$E+}
Default
{$E+}
Type
Remarks
or
{$E-}
Global
The $E directive enables or disables linking with a run-time library that
will emulate the 80x87 numeric coprocessor if one is not present.
When you compile a program in the {$N+,E+} state, Turbo Pascal links
with the fu1l80x87 emulator. The resulting .EXE file can be used on any
machine, regardless of whether an 80x87 is present. If one is found, Turbo
Pascal will use it; otherwise, the run-time library emulates it.
In the {$N+,E-} state, Turbo Pascal produces a program which can only be
used if an 80x87 is present.
The 80x87 emulation switch has no effect if used in a unit; it applies only
to the compilation of a program. Furthermore, if the program is compiled
in the {$N-} state, and if all the units used by the program were compiled
with {$N-}, then an 80x87 run-time library is not required, and the 80x87
emulation switch is ignored.
ENDIF directive
Syntax
Remarks
Conditional compilation
{$ENDIF}
213
Extended syntax
Extended syntax
Syntax
{$X +}
Default
{$X+}
Type
Remarks
The {$X+} directive
does not apply to
built-in functions
(those defined in
the System unit).
Switch
or
{$X - }
Global
The $X directive enables or disables Turbo Pascal's extended syntax:
Function statements. In the {$X+} mode, function calls can be used as
procedure calls; that is, the result of a function call can be discarded.
Generally, the computations performed by a function are represented
through its result, so discarding the result makes little sense. However,
in certain cases a function can carry out multiple' operations based on its
'parameters, and some of those cases may not produce a useful result. In
such cases, the {$X+} extensions allow the function to be treated as a
procedure .
Null-terminated strings. A {$X+} compiler directive enables Turbo
Pascal's support for null-terminated strings by activating the special
rules that apply to the built-in PChar type and zero-based character
arrays. For more details about null-terminated strings, see
Chapter 16, "Using null-terminated strings," in the Language Guide.
r
Switch
Syntax
{$F+}or {$F-}
Default
{$F-}
Type
Remarks
Local'
The $F directive determines which call model to use for subsequently
compiled procedures and functions. Procedures and functions compiled
in the {$F+} state always use the far call modeL In the {$F-} state, Turbo
Pascal automatically selects the appropriate model: far if the procedure or
function is declared in the interface section of a unit; otherwise it selects
near.
The near and far call models are described in full in Chapter 20, "Control
issues," in the Language Guide.
214
Programmerrs Reference
{ $G+} or {$G-}
Default
{ $G- }
Type
Remarks
Switch
Global
IFDEF directive
Syntax
Remarks
Conditional compilation
{ $IFDEF name}
IFNDEF directive
Syntax
Remarks
Conditional compilation
{ $IFNDEF name}
IFOPT directive
Syntax
Remarks
Conditional compilation
{$IFOPT switch}
215
Include file
Include file
Syntax
Type
Remarks
Parameter
{ $I filename}
Local
The $1 parameter directive instructs the compiler to include the named file
in the compilation. In effect, the file is inserted in the compiled text right
after the {$I filename} directive. The default extension for filename is .PAS. If
filename does not specify a directory path, then, in addition to searching
for the file in the current directory, Turbo Pascal searches in the directories
specified in the Options I Directories I Include Directories input box (or in
the directories specified in the II option on the TPC command line).
There is one restriction to the use of include files: An include file can't be
specified in the middle of a statement part. In fact, all statements between
the begin and end of a statement part must exist in the same source file.
Input/output checking
Syntax
{$I+}
Default
{$I+}
Type
Local
Remarks
or
{$I-}
Remarks
216
Switch
Parameter
{$L filename}
Local
The $L parameter directive instructs the compiler to link the named file
with the program or unit being compiled. The $L directive is used to link
with code written in assembly language for subprograms declared to be
external. The named file must be an Intel relocatable object file (.OBJ file).
Programmer's Reference
The default extension for filename is .OBJ. If filename does not specify a
directory path, then, in addition to searching for the file in the current
directory, Turbo Pascal searches in the directories specified in the
Options IDirectories IObject Directories input box (or in the directories
specified in the /0 option on the TPC command line). For further details
about linking with assembly language, see Chapter 23, "Linking
assembler code," in the Language Guide.
{$L+}
Default
{$L+ }
Type
Remarks
Switch
or {$L- }
Global
217
{$M stacksize,heapmin,heapmax}
Default
{$M 16384,~,655360}
Type
Remarks
Parameter
Global
The $M directive specifies an application's memory allocation parameters.
Numeric coprocessor
Syntax
{$N+}
Default
{ $N - }
Type
Remarks
or
{$N-}
Global
The $N directive switches between the two different models of floating. point code generation supported by Turbo Pascal. In the {$N-} state, code
is generated to perform all real-type calculations in software by calling
run-time library routines. In the {$N+} state, code is generated to perform
all real-type calculations using the 80x87 numeric coprocessor.
{$P+}
Default
{$p- }
Type
Remarks
218
Switch
or
Switch
{$p-}
Local
The $P directive controls the meaning of variable parameters declared
using the string keyword. In the {$P-} state, variable parameters declared
using the string keyword are normal variable parameters, but in the {$P+}
state, they are open string parameters. Regardless of the setting of the $P
directive, the OpenString identifier can always be used to declare open
Programmer's Reference
Overflow checking
Overflow checking
Syntax
{$Q+}
Default
{$Q-}
Type
Local
Remarks
Switch
or {$Q-}
{$O+}
Default
{$O- }
Type
Remarks
Switch
or {$O-}
Global
219
Remarks
Parameter
Local
The Overlay unit name directive turns a unit into an overlay.
The {SO unitname} directive has no effect if used in a unit; when compiling
a program, it specifies which of the units used by the program should be
place~ in an .OVR file instead of in the .EXE file.
{SO unitname} directives must be placed after the program's uses clause ..
Turbo Pascal reports an error if you attempt to overlay a unit that wasn't
compiled in the {$O+} state.
Range checking
Syntax
{$R+}
Default
{ $R- }
Type
Local
Remarks
Switch
or
{$R-}
verified as being within the defined bounds and all assignments to scalar
and subrange variables are checked to be within range. If a range check
fails, the program terminates and displays a run-time error message.
If $R is switched on, all calls to virtual methods are checked for the
initialization status of the object instance making the call. If the instance
making the call has not been initialized by its constructor, a range check
run-time error occurs.
Enabling range checking and virtual method call checking slows down
your program and makes it somewhat larger, so use the {$R+} only for
debugging.
220
Programmer's Reference
Stack-overflow checking
Syntax
{$S+}
Default
{$S+ }
.Type
Local
Remarks
or
{$S-}
{$Y+}
Default
{ $Y +}
Type
Remarks
Switch
or
Switch
{$Y-}
Global
The $Y directive enables or disables generation of symbol reference
information. This information consists of tables that provide the line
numbers of all declarations of and references to symbols in a module.
For units, the symbol reference information is recorded in the .TPU file
along with the unit's object code. Symbol reference information increases
the size of .TPU files, but it does not affect the size or speed of the
executable program.
When a program or unit is compiled in the {$Y+} state, Turbo Pascal's
integrated browser can display symbol definition and reference
information for that module.
The $Y switch is usually used in conjunction with the $0 and $L switches,
which control generation of debug information and local symbol
information. The $Y directive has no effect unless both $0 and $L are
enabled.
221
Type-checked p'ointers
Type-checked pOinters
Syntax
{$T+}
Default
{$T-}
Type
Remarks
or
{$T-}
Global
The $T directive controls the types of pointer values generated by the @
operator. In the {$T-} state, the result type of the @ operator is always
Pointer. In other words, the result is an untyped pointer that is compatible
with all other pointer types. When @ is applied to a variable reference in
the {$T+} state, the type of the result is AT, where T is the type of the.
variable reference. In other words, the result is of a type that is compatible
only with other pointers to the type of the variable.
UNDEF directive
Syntax
Remarks
Conditional compilation
{$UNDEF name}
Var-string checking
Syntax
{$V+}
Default
{$V+}
Type
Remarks
Switch
or
Switch
{$V-}
Local.
The $V directive controls type checking on strings passed as variable
parameters. In the {$V+} state, strict type checking is performed, requiring
the formal and actual parameters to be of identical string types. In the {$V-}
(relaxed) state, any string type variable is allowed as an actual parameter,
even if the declared maximum length is not the same as that of the formal
parameter.
The {$V-} state essentially provides an ('unsafe" version of open string
parameters. Although {$V-} is still supported, you should use .open string .
parameters. For additional information, see "Open string parameters" in
Chapter 9 in the Language Guide.
222
Programmer's Reference
causes either the source text between {$IFxxx} and {$ELSE} or the
source text between {$ELSE} and {$ENDIF} to be compiled,
depending on the condition specified by the {$I Fxxx}.
Here are some examples of conditional compilation constructs:
{$IFDEF Debug}
writeln(/X =
{$ENDIF}
"
Xl;
{$IFDEF CPU87}
{$N+}
type
Real
{$ELSE}
{$N-}
= Double;
type
Single = Real;
Double = Real;
Extended = Real;
Comp = Real;
{$ENDIF}
223
Conditional
symbols
You can also use the /0 switch in the command-line compiler (or
place it in the Conditional Defines input box from within
Options I Compiler of the IDE).
Conditional symbols are best compared to Boolean variables:
They are either True (defined) or False (undefined). The {$OEFINE}
directive sets a given symbol to True, and the {$UNOEF} directive
sets it to False.
Conditional symbols follow the same rules as Pascal identifiers:
They must start with a letter, followed by any combination of
letters, digits, and underscores. They can be of any length, but
only the first 63 characters are significant.
Conditional symbols and Pascal identifiers have no correlation
whatsoever. Conditional symbols cannot be referenced in the
actual program and the program's identifiers cannot be referenced
in conditional directives. For example, the construct
const
Debug = True;
begin
{$IFDEF Debug}
Writeln('Debugis on');
{$ENDIF}
end;
224
Programmer's Reference
VER70
MSOOS
CPU86
CPU87
225
226
Programmer's Reference
Command-line compiler
Turbo Pascal command-line compiler (TPC.EXE) lets you invoke
all the functions of the IDE compilers (TURBO.EXE and TPX.EXE)
from the DOS command line.
If you need help using the
command-line compiler, you
can get online help by
typing THELP at the
command line.
You run TPC.EXE from the DOS prompt using a command with
the following syntax:
TPC [options] filename [options]
227
The first command line uses hyphens with at least one blank
separating the options; the second uses slashes, and no separation
is needed.
The following table lists the command-line options:
Table 3.1
Command-line options
Option
'$A+
I$AIf you type TPC alone at the
command line, a list of
command-line compiler
options appears on your
screen.
1$8+
1$8.1$0+
1$0-
I$E+
I$EI$F+
I$FI$G+
I$G1$1+
1$1I$L+
I$L-
I$Mstack,min,max
I$N+
I$N1$0+
1$0I$P+
I$P1$0+
1$0I$R+
I$R1$5+
1$5I$T+
I$TI$V+
I$VI$X+
228
Description
Programmers Reference
!$X-
18
lOdefines
IEpath
IFsegment:offset
IGS
IGP
IGO
Ilpath
IL
1M
IOpath
10
fTpath
IUpath
N
Compiler
directive options Turbo Pascal supports several compiler directives, all of which are
described in Chapter 2, "Compiler directives."
The 1$ and 10 command-line options let you change the default
states of most compiler directives. Using 1$ and 10 on the
command line is equivalent to inserting the corresponding
compiler directive at the beginning of each source file compiled.
The switch directive
option
The 1$ option lets you change the default state of all the switch
directives. The syntax of a switch directive option is 1$ followed
by the directive letter, followed by a plus (+) or a minus (-). For
example,
TPC MYSTUFF /$R-
Alternately, TPC lets you write a list of directives (except for $M),
separated by commas:
229
Note that, because of its format, you cannot use the $M option in a
list of directives separated by commas.
The conditional defines
option
. defines three conditional symbols, iocheck, debug, and list, for the
compilation of MYSTUFF.PAS. This is equivalent to inserting
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
Compiler mode
options
A few options affect how the compiler itself functions. These are
1M (Make), 18 (Build), IF (Find Error), IL (Link Buffer), and IQ
(Quiet). As with the other options, you can use the hyphen format
(remember to separate th~ options with at least one blank).
230
Programmer's Reference
231
If you do a DIR TEST.*, DOS lists two files: TEST. PAS, your
In order for TPC to find the run-time error with IF, you must
232
Programmer's Reference
The quiet mode option suppresses the printing of file names and
line numbers during compilation. When TPC is invoked with the
quiet mode option
TPC MYSTUFF /Q
its output is limited to the sign-on message and the usual statistics
at the end of compilation. If an error occurs, it will be reported.
Directory options
TPC supports several options that let you specify the five
directory lists used by TPC: TPL & CFG, EXE & TPU, Include,
Unit, and Object.
Excluding the EXE and TPU directory option, you may specify
one or multiple directories for each command-line directory
option. If you specify multiple directories, separate them with
semicolons (;). For example, this command line tells TPC to search
for Include files in C: \ TP \ INCLUDE and D: \ INC after searching
the current directory:
TPC MYSTUFF /IC:\TP\INCLUDEiD:\INC
If you want the IT option to affect the search for TPC.CFG, it must
be the very first command-line argument, as in the previous
example.
233
This option lets you tell TPC where to put the .EXE and .TPU files
it creates. It takes a directory path as its argument:
TPC MYSTUFF /EC:\TP\BIN
If no such option is given, TPC creates the .EXE and .TPU files in
the same directories as their corresponding source files.
When you compile a program that uses units, TPC first attempts
to find the units in TURBO.TPL (which is loaded along with
TPC.EXE). If they cannot be found there, TPC searches for
unitname.TPU in the current directory. The IU option lets you
specify additional directories in which to search for units.
Using {$L filename} compiler directives, Turbo Pascal lets you link
in .OBI files containing external assembly language routines, as
explained in Chapter 23, "Linking assembler code," in the
Language Guide. The 10 option lets you specify a list of directories
in which to search for such .OBI files.
Debug options
TPC has two command-line options that enable you to generate
debugging information: the map file option and the debugging
option.
The map file (fG)
option
234
Programmer's Reference
235
236
Programmer's Reference
Error messages
This chapter describes the possible e~ror messages you can get
from Turbo Pascal during program development. The error
messages are grouped according to the categories listed in
Table 4.1. Run-time errors are subdivided.into DOS, I/O, critical,
and fatal errors. Within each of the groups, the errors are listed in
numerical order.
Table 4.1
Error message types
Type of message
Page
Compiler
DOS
I/O
Critical
Fatal
237
and the source line, and uses a caret (/\) to indicate where the
error occurred. Note, however, that some errors are not detected
until a little later in the source text. For example, a type mismatch
in an assignment statement cannot be detected until the entire
expression after the := has been evaluated. In such cases, look for
the error to the left of or above the cursor.
1. Out of memory.
This error occurs when the compiler runs out of memory. Try
these possible solutions:
If Compile I Destination is set to Memory, set it to Disk in the
integrated environment.
If Options I Linker I Link Buffer is set to Memory, toggle it to
Disk. Use a IL option to place the link buffer on disk when
using the command-line compiler.
If these suggestions don't help, your program or unit might
simply be too large to compile in the amount of memory available, and you might have to break it into two or more smaller
units.
2 Identifier expected.
An illegal character was found in the source text. You might have
forgotten the quotes around a string constant.
238
Programmer's Reference
You might have gotten this error message for one of the following
reasons:
Your source file ends before the final end of the main statement
part. Most likely, your begin and end statements do not match.
An Include file ends in the middle of a statement part. Every
statement part must be entirely contained in one file.
You didn't close a comment.
11 Line too long.
, 239
The compiler could not find the file in the current directory or in
any of the search directories that apply to this type of file.
16 Disk full.
240
Programmer's Reference
Real types, string types, structured types, and pointer types are
not allowed here.
30 Integer constant expected.
241
31 Constant expected.
32 Integer or real constant expected.
33 Pointer type identifier expected.
Valid function result types are all simple types, string types, and
pointer types.
35 . Label identifier expected.
242
Programmer's Reference
42 Error in expression.
The .OB] file contains an invalid object record; make sure. the file
is in fact an .OB] file.
48 Code segment too large.
243
Turbo Pascal cannot handle .OBJ files with more than 256 EXTRN
definitions.
54 OF expected.
244
Programmer's Reference
245
Two units are not allowed to use each other in the interface part.
It is legal for two units to use each other in the implementation
part. Rearrange your uses clauses so that circular references occur
only in the implementation parts. For more details, see "Circular
unit references" in Chapter 10 in the Language Guide.
69 Unit name mismatch.
The name of the unit found in the .TPU file does not match the
name specified in the uses clause.
70 Unit version mismatch.
One or more of the units used by this unit have been changed
since the unit was compiled. Use Compile I Make or Compile I
Build in the IDE and 1M or IB options in the command-line
compiler to automatically compile units that need recompilation.
71 Internal stack overflow.
246
Programmer's Reference
247
argument.
248
Programmer's Reference
90
"=" expected.
249
The length of the string constant does not match the number of
components in the character array.
101 Invalid ordering of ,fields.
The size of the relocation table part of the .EXE file exceeds 64K,
which is Turbo Pascal's upper limit. If you encounter this error,
your program is simply too big for Turbo Pascal's linker to
handle. It is probably also too big for DOS to execute. You will
have to split the program into a "main" part that executes two or
more "subprogram" parts using the Exec procedure in the Dos
unit.
250
Programmer's Reference
251
You are attempting to declare a file-type value parameter. Filetype parameters must be var parameters.
127 Too many conditional symbols.
252
Programmer:S Reference
253
Your TURBO. TPL library must contain the System unit for the
debugger to be able to evaluate expressions.
139 Cannot access this symbol.
254
Programmer's Reference
The file could not be opened or created. Most likely, the compiler
is trying to write to a read-only file.
147 Object type expected.
255
256
Programmer's Reference
Run-time errors
Certain errors at run time cause the program to display an error
message and terminate:
Run-time error nnn at xxxx:yyyy
257
The run-time errors are divided into four categories: DOS errors, 1
through 99; I/O errors, 100 through 149, critical errors, 150
through 199; and fatal errors, 200 through 255.
DOS errors
1 Invalid function number.
258
Programmer's Reference
259
I/O errors
These errors cause termination if the particular statement was
compiled in the {$I+} state. In the {$I-} state, the program
continues to execute, and the error is reported by the IOResult
function.
100 Disk read error.
Reported by Write and Writeln on a text file if the file is not open
for output.
106 Invalid numeric format.
260
Programmer's Reference
Critical Errors
For more information about these errors, see your DOS
programmer's reference manual.
150 Disk is write protected.
151 Unknown unit.
152 Drive not ready.
153 Unknown command.
154 CRC error in data.
155 Bad
driv~
Fatal errors
These errors always immediately terminate the program.
200 Division by zero.
261
This error is reported on entry to a procedure or function compiled in the {$S+} state when there is not enough stack space to
allocate.the subprogram's local variables. Increase the size of the
stack by using the $M compiler directive.
This error might also be caused by infinite recursion, or by an
assembly language procedure that d()es not maintain the stack
properly.
203 Heap overflow error.
262
Programmer's Reference
263
264
Programmer's Reference
A
Editor reference
The tables in this appendix list all the available editing commands
you can use in the Turbo Pascal IDE. If two sets of key
combina tions can be used for a single command, the second set is
listed as an alternate key combination. Footnoted references in
Table A.l mark those commands that are described in depth in
Tables A.2, A.3, and A.4.
265
Table Al
Editing commands
Command
Keys
Alternate Keys
Ctrl+S
Ctrl+D
Ctrl+A
Ctrl+F
Ctrl+E
Ctrl+X
Character left
, Character right
Word left
Word right
Lineup
Line down
Scroll up one line
Scroll down one line
Page up
Page down
Beginning of line
A word is defined as a
sequence of characters
separated by one of the
fol/owing: space < > , ;
.()()/\'*+-/$
#=I-?'''%&':
@ \,
End of line
Top of window
Bottom of window
Top of file,
Bottom of file
Move to previous position
Ctrl+~
Ctrl+~
,t
Ctrl+W
Ctrl+Z
PgUp
PgDn
Home
Ctrl+Q S
End
Ctrl+Q D
Ctrl+Q E
Ctrl+QX
Ctrl+Q R
Ctrl+Q C
Ctrl+Q P
Ctrl+R
Ctrl+C
Ctrl+Home
Ctrl+End
Ctrl+PgUp
Ctrl+PgDn
Delete character
Delete character to left
Delete line
Delete to end of line
Delete to end of word
Insert newline
Insert mode on/off
Del
Backspace
Shift+Tab
Ctrl+Y
Ctrl+Q Y
Ctrl+T
Ctrl+N
Ins
Ctrl+G
Ctrl+H
Ctrl+V
Block commands
*
t
:j:
266
Ctrl+Q B
Ctrl+Q K
Ctrl+K B
Ctrl+K K
Ctrl+K D
Ctrl+KH
Ctrl+K L
Ctrl+KP
Ctrl+KT
Ctrl+KY
Programmer's Reference
Keys
Copy block
Move block
Copy to Clipboard :j:
Cut to Clipboard :j:
Delete block :j:
Indent block
Paste from Clipboard :j:
Read block from disk :j:
Unindent block
Write block to disk:j:
Ctr/tK C
Ctr/tK V
Ctr/t/ns
ShifttDe/
Ctr/tDe/
Ctr/tK /
Shiftt/ns
Ctr/tK R
Ctr/tK U
Ctr/tKW
Alternate Keys
Shiftt fShiftt ~
ShifttEnd
ShifttHome
Shiftt .t
Shiftt l'
ShifttPgDn
ShifttPgUp
ShifttCtr/t fShifttCtr/t ~
ShifttCtr/tEnd
ShifttCtr/tHome
ShifttCtr/tPgDn
ShifttCtr/tPgUp
Ctr/tO /
Ctr/tO R
A/ttX
Ctr/tOn *
F1
ShifttF1
Ctr/tpt
F5
F3
Ctr/tO F
Ctr/tO [,
Ctr/tO J
Ctr/tK S
Ctr/tO F
F2
Ctr/+L
Ctr/tOA
267
*
t
Command
Keys
Alternate Keys
Set marker #
Tabs mode on/off #
Topic search help
Undo
Unindent mode on/off #
Display compiler directives
Ctrl+K n *
Ctrl+O T
Ctrl+F1
Alt+Backspace
Ctrl+O U
Ctrl+O 0
Keys
Function
Ctrl+lns,
Shift+lns
Copy to Clipboard
Ctrl+lns
Cut to Clipboard
Shift+Del
Delete block
Ctrl+Del
Shift+Del,
Shift+lns
Paste from
Clipboard
Shift+lns
Read block
from disk
Ctrl+K R
Write block
to disk
Ctrl+KW
268
Programmer's Reference
If you have used Borland editors in the past, you might prefer to
use the block commands listed in the following table.
Table A.3
Borland-style block
commands
Selected text is highlighted
only if both the beginning
and end have been set and
the beginning comes before
the end.
Editor commands
in depth
Command
Keys
Function
Hide/show block
Copy block
Move block
Keys
Function
Ctr/+O /
Cursor through
tabs on/off
Ctr/+O R
Find place
marker
Ctr/+Qn'
Open file
F3
Ctr/+O F
Toggles optimal fill. Optimal fill begins every line with the
minimum number of characters possible, using tabs and spaces
as necessary. This produces lines with fewer characters.
Save file
F2
269
Keys
Function
Set marker
Ctr/+K n *
Ctr/+O T
Toggles Tab mode. You can specify the use of true tab
characters in the IDE with the Options I Editor Use Tab
Character option.
Ctr/+O U
Toggles Unindent. You can turn Unindent on and off from the
IDE with the Options I Editor Backspace Unindents option.
Expression
Function
------------------------~-------------------------------
$
*
[]
[-]
270
Programmer's Reference
B
Compiler directives quick reference
This appendix lists all of the Turbo Pascal compiler directives. It shows
the syntax as you would enter it in your source code, displays the
. command-line equivalent, and briefly describes each directive.
Asterisks (*) indicate the default setting. For example, the default setting
for debug information {$D+} is on.
Table B.l: Compiler directives
Directive
Source Code
Syntax
Default
Command-line
Description
/$A+
{$A-}
/$A-
{$B+}
/$B+
{$B-}
/$8-
Debug information
on
{$D+}
/$0+
Debug information
off
{$D-}
/$0-
{$A+}
271
Source Code
Syntax
DEFINE
{DEFINE
ELSE
{ELSE}
Emulation on
{$E+}
Emulation off
{$E-}
ENDIF
{$ENDIF}
Default
name}
Command-line
/Dname
I$E+
I$E-
Description
Extended syntax1
/$F+
/$F-
/$G+
/$G-
/$1+
/$1-
{$F+}
{$F-}
80286 code
generation on
{$G+}
80286 code
generation off
{$G-}
Input! output
checking on
{$I+}
Input! output
checking off
{$I-}
Include file
{$I filename}
IFDEF
{IFDEF name}
IFNDEF
{IFNDEF name}
272
Programmer's Reference
Directive
Default
Command-line
Description
IFOPT
{lFOPT switch}
{$L filename}
Local symbol
information on
{$L+}
Local symbol
information off
Memory allocation
sizes
/$L+
{$L-}
/$L-
{$M}stacksize,
heapmin,heapmax
Specifies an application or
/ $Mstacksize,
heapmin,heapmax library'S memory allocation
parameters.
Numeric coprocessor
on
{$N+}
Numeric coprocessor
off
{$N-}
Open parameters on
{$P+}
{$P-}
/$N+
/$N-
/$P+
/$P-
/$Q+
/$Q-
/$0+
/$0-
/$R+
Overlay code
generation
{$O+}
Overlay code
generation
{$O-}
Range checking on
{$R+}
{$R-}
/$R-
Stack-overflow
checking on
{$S+}
/$S+
Generates stack-overflow
checking code.
273
Source Code
Syntax
Default
Command-line
Description
{$S-}
/$S-
/$T+
/$T-
Stack-overflow
checking off
,{UNDEF name}
Var-string. checking
on
{$V+}
Var-string checking
off
{$V-}
Extended syntax on
{$X+}
{$X-}
274
/$V+
/$V-
/$X+
/$X-
Programmer,s Reference
c
Reserved words and standard
directives
This appendix lists the Turbo Pascal reserved words and standard
directives.
Reserved words and standard directives appear in lowercase
boldface throughout the manuals. Turbo Pascal isn't case
sensitive, however, so you can use either uppercase or lowercase
letters in your programs.
Reserved words have a special meaning to Turbo Pascal; you
can't redefine them.
Table C.l
Turbo Pascal reserved words
and
array
asm
begin
case
const
constructor
destructor
div
do
downto
else
end
file
for
function
goto
if
implementation
in
inherited
inline
interface
label
mod
nil
not
object
of
or
packed
procedure
program
record
repeat
set
shl
shr
string
then
to
type
unit
until
uses
var
while
with
xor
275
absolute
assembler
external
far
forward
interrupt
near
private
public
resident
virtual
276
Programmer's Reference
D
ASCII characters
This appendix contains a table that lists the American Standard
Code for Information Interchange (ASCII) characters. ASCII is a
code that translates alphabetic and numeric characters and
symbols and control instructions into 7-bit binary code. Table D.l
shows both printable characters and control characters.
277
Table D.l
ASCII table
o
The caret in A@ means to
press the elrl key and type @.
1
2
4
5
6
A@ NUL
1
2
3
4
5
6
7
8
BEL
BS
TAB
10
11
12
LF
o-VT
FF
13
jl
CR
14
15
16
17
18
19
20
21
SO
S1
10
11
12
22
23
24
25
26
27
28
29
30
31
278
SOH
STX
ETX
EOT
.to ENQ
.. ACK
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
DLE
... DC1
DC2
!! DC3
~ DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
.. RS
~ US
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
45
46
47
48
49
50
51
52
53
54
55
56
57
.58
59
60
61
62
63
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
$
J\(
&
(
)
*
+
77
o
1
2
3
4
5
6
7
8
9
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<
>
92
93
94
95
40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
B
C
D
E
F
G
H
I
J
K
L
M
o
p
Q
R
S
T
U
V
W
X
Y
Z
\
]
A
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F
70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F
a
b
c
d
e
f
9
h
j
k
m
n
o
p
q
s
t
u
v
w
x
y
Z
Programmer's Reference
128
129
130
131
132
133
134
135
136
137
138
139
80
81
82
83
84
85
86
87
88
89
8A
8B
C(
140
141
142
143
144
145
146
147
148
149'
150
151
152
153
154
155
156
157
158
159
8C
8D
8E
8F
90
91
92
93
94
95
96
97
98
99
9A
9B
9C
9D
9E
9F
'I
jj
e
a
a
a
a
c;
e
e
e
;'
A
E
a!
If.
a
o
o
Q
o
o
PI
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
AO
A1
A2
A3
A4
A5
A6
A7
A8
A9
6
U
fi
N
a
o
AA
AB
AC
AD
AE
AF
BO
B1
B2
B3
B4
B5
B6
B7
B8
B9
BA
BB
BC
BD
BE
BF
m
II
I
i
=l
~I
11
{I
II
il
:!J
lJ
d
1
co
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
DO
Dl
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
.L
Ii'
:!!:
JL
lr
:!:
II
If
lL
If
=f
I
I
EO
E1
E2
E3
E4
E5
E6
E7
E8
E9
EA
EB
EC
ED
EE
EF
FO
F1
F2
F3
F4
F5
F6
F7
F8
F9
FA
FB
FC
FD
FE
FF
ex
B
r
IT
a
J1
T
cJ>
()
o
o
00
ifJ
E
n
2
279
280
Programmer's Reference
AssignCrt procedure 10
Assigned function 10
autoindent mode 267, 269
Index
281
Borland-style 269
unindent 267
write to disk 267, 268
BlockRead procedure 13
BlockWrite procedure 14
Blue constant 22
Blue text color constant 192
Boolean evaluation
compiler switch 211
complete 211
short circuit 211
Borland, contacting 2-4
BottomText constant 99
Break procedure 15
Brown constant 22
Brown text color constant 192
buffer, assigning to text file 168
buffers, flushing 54
Build command 231
build command-line option 231
BW40 mode constant 26
BW80 mode constant 26
bytes, copying 108
c
C040 mode constant 26
C080 mode constant 26
C40 mode constant 26
C80 mode constant 26
CenterLn constant 101
CenterText constant 99
CGA25
changing directories 15
characters
, convert to uppercase 200
delete 266
filling string with 49
ordinal number of 17
ChDir procedure 15
CheckBreak variable 16
CheckEof variable 16
CheckSnow variable 16
Chr function 17
Circle procedure 17
Clear command 268
ClearDevice procedure 18
clearing the overlay buffer 116
282
ClearViewPort procedure 19
Clipboard
copy to 267
cut to 267
paste from 267, 268
ClipOff constant 19
ClipOn constant 19
clipping constants 19
clipping parameters 79
Close procedure 20
CloseDotFill constant 49
CloseGraph procedure 20
ClrEol procedure 21
ClrScr procedure 21
colors 67
background 60
changing text 192
constants 22
constants for SetRGBPalette 22
drawing 62
command-line
compiler reference 227-236
options 229-235
/B231
/D230
debug 234
/E234
/F 231
/G234
/GD234
/GP 234
/GS234
/1234
/L232
/M231
mode 230
, /0234
/Q232
switching directive defaults (/$) 229
/T 233
/U234
/V 235
command-line compiler
arguments 227
compiling and linking with 227
extended syntax 228
options 227
Programmer's Reference
Index
$198,216
$IFDEF 215
$IFNDEF 215
$IFOPT 215
$L 216, 217
$M 99, 106, 124,218,230
$N218
$0219,220
$P218
parameter 210
$R220
$S221
switch 209
$UNDEF 222, 224
$V222
$X214
$Y 221
error messages 237
compiling to .EXE file 231
Complete Boolean Eval option 211
CompuServe, Borland information 2
ComStr type 44
Concat function 23
concatenating strings 23
conditional
defines (command-line option) 230
symbols 224
CONFIG.SYS 121
configuration file
TPC.CFG235
Continue procedure 23
control characters 277
insert 267
copy block 267
Borland-style 269
Copy Junction 24
copy to Clipboard 267
283
copying
bytes 108
substrings 24
CopyPut constant 13
Cos function 25
cosine of an argument 25
CPU symbols 225
CreateDir procedure 25
critical errors 261
Crt unit
AssignCrt procedure 10
ClrEol procedure 21
ClrScr procedure 21
Delay procedure 27
DelLine procedure 28
GotoXY procedure 81
HighVideo procedure 88
InsLine procedure 93
KeyPressed function 99
LowVideo procedure 105
NormVideo procedure 111
NoSound procedure 112
ReadKey function 135
Sound procedure 176
TextBackground procedure 192
TextColor procedure 193
TextMode procedure 194
WhereX function 202
WhereY function 202
Window procedure 203
CS register value 26
CSeg function 26
cursor position
reading 202
setting 81
cursor through tabs 267, 269
customer assistance 2-4
cut to Clipboard 267
Cyan constant 22
Cyan text color constant 192
D
/D command-line option 230
$D compiler directive 212, 231
DarkGray constant 22
DarkGray text color constant 192
DashedLn constant 101
284
Programmer's Reference
DirStr type 44
DiskFree function 30
disks, space 30
DiskSize function 30
Dispose procedure 30
DOS
Pascal functions for 110
verify flag 79
setting 172
Dos unit
DiskFree function 30 .
DiskSize function 30
DosExitCode function 32
DosVersion function 32
EnvCount function 36
EnvStr function 36
Exec procedure 39
FExpand function 42
FindFirst procedure 51
FindNext procedure 52
FSearch function 57
FSplit procedure 57
GetCBreak procedure 61
GetDate procedure 63
GetEnv function 65
GetFAttr procedure 66
GetFTime procedure 68
GetIntVec procedure 71
GetTime procedure 78
GetVerify procedure 79
Intr procedure 97
Keep procedure 99
MsDos procedure 110
PackTime procedure 125
SetCBreak procedure 155
SetFTime procedure 160
SetIntVec procedure 161
SetTime procedure 171
SetVerify 172
SwapVectors procedure 189
UnpackTime procedure 200
DosError variable 31, 39, 160
DosExitCode function 32
DosVersion function 32
DottedLn constant 101
DrawPoly procedure 32
driver constants 33
Index
drivers
active 64
maximum mode number 72
DS register value 35
DSeg function 35
dynamic variables, creating 74
E
IE command-line option 234
$E compiler directive 213
edit windows, moving cursor in 266
editing
block operations 266
deleting 268
reading and writing 268
commands
cursor movement 266
insert and delete 266
EGABlack constant 23
EGABlue constant 23
EGABrown constant 23
EGACyan constant 23
EGADarkGray constant 23
EGAGreen constant 23
EGALightBlue constant 23
EGALightCyan constant 23
EGALightGray constant 23
EGALightGreen constant 23
EGALightMagenta constant 23
EGALightRed constant 23
EGAMagenta constant 23
EGARed constant.23
EGAWhite constant 23
EGAYellow constant 23
ellipse, drawing 49
Ellipse procedure 35
elliptical sector, drawing and filling 148
$ELSE compiler directive 213
EmptyFill constant 48
emulating numeric coprocessor (8087)
compiler switch 213
Emulation
command 213
option 213
end-of-file
error messages 239
status 36, 37, 149
285
F
IF command-line option 231
$F compiler directive 214
far calls, forcing use of models in 214
fatal run-time errors 261
FAuxiliary constant 53
FCarry constant 53
fcDirectory constant 42
fcExtension constant 42
fcFileName constant 42
286
fcWildcards constant 42
fcXXXX constants 42
FcXXXX flag constants 48
FExpand function 42
file
expanding file names 44
open 267, 269
position 45
reading file components 135
save 267, 269
size of 47
split into components 47
file attribute constants 43
file-handling procedures
Rename 142
Reset 142
Rewrite 144
Seek 149
SetFAttr 157
Truncate 198
file-handling string types 44
file mode constants 55
file name length constants 43
file record types 46, 195
FileExpand function 44
FileMode variable 45
FilePos function 45
FileRec type 46
files
access-denied error 258
attributes 66
closing 20
creating new 144
erasing 38
.MAP234
.OBJ 234
linking with 216
opening existing 142
record definition for 197
text, record definition 199
truncating 198
untyped, variable 13, 14
FileSearch function 46
FileSize function 47
FileSplit constants 42
FileSplit function 44,47
fill pattern constants 48
Programmer's Reference
fill patterns 67
FillChar procedure 49
FillEllipse procedure 49
filling areas 53
FillPattemType type 50
FillPoly procedure 50
FillSettingsType type 51
Find Error command 231, 232
find error command-line option 231
FindFirst procedure 43, 51
FindNext procedure 52
flag constants in Dos unit 53
flag constants in WinDos unit 53
floating-point errors 262
FloodFill procedure 53
Flush procedure 54
fmClosed constant 55
fmInOut constant 55
fmInput constant 55
fmOutput constant 55
fmXXXX constants 55
font control constants 55
Font8x8 mode constant 26
Font8x8 variable 194, 195
fonts
installing 96
stroked 171
Force Far Calls
command 214
option 214
force far calls compiler switch 214
FOverflow constant 53
FParity constant 53
Frac function 55
fractions, returning 55
FreeList variable 56
FreeMeni. procedure 56
fsDirectory constant 44
FSearch function 57
fsFileName constant 44
FSign constant 53
fsPathName constant 44
FSplit procedure 43, 57
fsWildCards constant 44
FsXXXX constants 48
fsXXXX constants 43
Index
functions
discarding results 214
extended syntax and 214
FXXXX constants 53
fXXXX constants 53
FZero constant 53
G
/G command-line option 234
$G compiler directive 215
/ GD command-line option 234
GEnie, Borland information 2
GetArcCoords procedure 58
GetArgCount function 59
GetArgStr function 59
GetAspectRatio procedure -59
GetBkColor function 60
GetCBreak procedure 61
GetColor function 62
GetCurDir function 62
GetDate procedure 63
GetDefaultPalette function 63
GetDir procedure 64
GetDriverName function 64
GetEnv function 65
GetEnvVar function 66
GetFAttr procedure 43, 66
GetFillPattem procedure 67
GetFillSettings procedure 67
GetFTime procedure 68
GetGraphMode function 69
GetImage procedure 70
GetIntVec procedure 71
GetLineSettings procedure 71
GetMaxColor function 72
GetMaxMode function 72
GetMaxX function 73
GetMaxY function 74
GetMem procedure 74
GetModeName function 75
GetModeRange procedure 75
GetPalette procedure 76
IBM 8514 and 76
GetPaletteSize function 77
GetPixel function 77
GetTextSettings procedure 78
GetTime procedure 78
287
GetVerify procedure 79
GetViewSettings procedure 79
GetX function 80
GetY function 81
GothicFont constant 55
GotoXY procedure 81
/GP command-line option 234
Graph unit
Arc procedure 8
Bar3D procedure 12
Bar procedure 11
Circle procedure 17
ClearDevice procedure 18
ClearViewPort procedure 19
CloseGraph procedure 20
DetectGraph procedure 28
DrawPoly procedure 32
Ellipse procedure 35
FillEllipse procedure 49
FillPoly procedure 50
FloodFill procedure 53
GetArcCoords procedure 58
GetAspectRatio procedure 59
GetBkColor function 60
GetColor function 62
GetDefaultPalettefunction 63
GetDriverName function 64
GetFillPattern procedure 67
GetFillSettings procedure 67
GetGraphMode function 69
GetImage procedure 70
GetLineSettings procedure 71
GetMaxColor function 72
GetMaxMode function 72
GetMaxX function 73
GetMaxY function 74
GetModeName function 75
GetModeRange procedure 75
GetPalette procedure 76
GetPaletteSize function 77
GetPixel function 77
GetTextSettings procedure 78
GetViewSettings procedure 79
GetX function 80
GetY function 81
GraphDefaults procedure 82
GraphErrorMsg function 82
288
GraphResult function 84
ImageSize function 88
InitGraph procedure 90
InstallUserDriver function 94
InstallUserFont function 96
Line procedure 100
LineRel procedure 102
LineTo procedure 103
MoveRel procedure 109
MoveTo procedure 110
OutText procedure 113
OutTextXY procedure 115
PieSlice procedure 127
PutImage procedure 130
PutPixel procedure 132
Rectangle procedure 136
RegisterBGIdriver function 137
RegisterBGIfont function 139
RestoreCrtMode procedure 143
Sector procedure 148
SetActivePage procedure 152
SetAllPalette procedure 152
SetAspectRatio procedure 154
SetBkColor procedure 155
SetColor procedure 156
SetFillPattern procedure 158
SetFillStyle procedure 159
SetGraphBufSize procedure 160
SetGraphMode procedure 160
SetLineStyle procedure 162
SetPalette procedure 163
SetRGBPalette procedure 164
SetTextJustify procedure 169
SetTextStyle procedure 169
SetUserCharSize procedure 171
SetViewPort procedure 172
SetVisualPage procedure 173
SetWriteMode 174
TextHeight function 193
TextWidth function 196
GraphDefaults procedure 82
GraphDriver variable
IBM 8514 and 91
. GraphErrorMsg function 82
GraphFreeMemPtr variable 83
GraphGetMemPtr variable 83
Programmer's Reference
graphics
bit-image operations 130
cards 28,91
drawing operations 100, 102, 103, 127, 136,
162
drivers 90
fill operations 158, 159
mode 69, 90, 101, 102, 103
page operations 152, 173
palette operations 152, 155, 156, 163
plotting operations 132
pointer operations 110
polygons, drawing 32
resolution 59
system operations 160
text operations 113, 115, 169, 193
video mode operations 143
viewport operations 172
GraphMode procedure 90
GraphResult function 84
error codes 84
Green constant 22
Green text color constant 192
grError constant 85
grFileNotFound constant 85
grFontNotFound constant 85
grInvalidDriver constant 85
grInvalidFont constant 85
grInvalidFontNum constant 85
grInvalidMode constant 85
grIOerror constant 85
grNoFloodMem constant 85
grNoFontMem constant 85
grNoInitGraph constant 85
grNoLoadMem constant 85
grNoScanMem constant 85
grNotDetected constant 85
grOk constant 85
grXXXX constants 85
IGS command-line option 234
H
Halt procedure 85
HatchFill constant 49
heap
end function, poiilter to 86
error function, pointer to 86
Index
I/O
checking 98, 216
error-checking 216
errors 260
operation, status of last 98
1/0 Checking
command 216
option 216
IBM 8514
GetPalette procedure and 76
GraphDriver variable and 91
InitGraph procedure and 91
palette entries, modifying 164
SetAllPalette procedure and 153
SetPalette procedure and 163
. $IFDEF compiler directive 215
$IFNDEF compiler directive 215
$IFOPT compiler directive 215
ImageSize function 88
Inc procedure 89
Include directories command-line option 216,
'234
289
J
justification, font 78
justification constants 99
K
Keep procedure 99
keyboard operations 99, 135
KeyPressed function 99
L
IL command-line option 232
$L compiler directive 216, 217
LastMode variable 100
LeftText constant 99
Length function 100
length of file name string 43
290
LightBlue constant 22
LightBlue text color constant 192
LightCyan constant 22
LightCyan text color constant 192
LightGray constant 22
LightGray text color constant 192
LightGreen constant 22
LightGreen text color constant 192
LightMagenta constant 22
LightMagenta text color constant 192
LightRed constant 22
LightRed text color constant 192
line
drawing, setting writing mode for 174 .
mark a 266
settings 71
Line procedure 100
line style constants 101
LineFill constant 48
LineRel procedure 102
lines
delete 266
insert 266
LineSettingsType type 103
LineTo procedure 103
Link Buffer option 232
linking
buffer option 232
object files 216
Ln function 104
Lo function 104
local symbol information switch 217
Local Symbols
command 217
option 217
logarithm, natural 104
Low function 104
low-order bytes 104
swapping 188 .
LowVideo procedure 105
Lst variable 106
LtBkSlashFill constant 48
LtSlashFill constant 48
M
1M command-line option 231
$M compiler directive 99, 106, 124,218,230
Programmer's Reference
Magenta constant 22
Magenta text color constant 192
Make command 231
make command-line option 231
map file command-line option 234
.MAP files 234
marker
find 267, 269
set 268,270
MaxAvail function 106
MaxColors constant 107
MemAvail function 107
memory 74
allocation 230
compiler directive 218
block, size of largest 106
error messages 238
free amount of 107
freeing 30, 56
size 218
MkDir procedure 108
mode constants, video 33
Mono mode constant 26
move block 267
Move procedure 108
MoveRel procedure 109
MoveTo procedure 110
MsDos procedure 110
MSDOS symbols 225
N
$N compiler directive 218
NameStr type 44
nesting files 216
New procedure 111
extended syntax, constructor passed as
parameter 111
NormVideo procedure 111
NormWidth constant 102
NoSound procedure 112
NotPut constant 13
null-terminated strings, compiler directive 214
number, random 132
numeric coprocessor, compiler'switch 218
numeric value, convert to string 178
Index
o
/0 command-line option 234
$0 compiler directive 219, 220
.OBJ files 234
linking with 216
object
directories, compiler directive 216
files, linking with 216
segment of 150
object directories command-line option 234
Odd function 112
odd number 112
offset of an object 112
Ofs function 112
online information services 2
Open a File dialog box 269
Open command 269
open file 267, 269
open string parameters compiler switch 218
Optimal Fill option 267, 269
Ord function 112
ordinal number of a character 17
ordinal value, of expression 112
OrPut constant 13
out-of-memory errors 238
output file, name of standard 113
Output variable 113
OutText procedure 113
OutTextXYprocedure 115
overflow checking 219
overlay buffers
clearing 116
returning size 118
setting size 123
Overlay unit
, OvrClearBuf procedure 116
OvrGetBuf function 118
OvrGetRetry function 118
OvrInit procedure 120
OvrInitEMS procedure 121
OvrSetBuf procedure 123
OvrSetRetry procedure 124
overlay unit name 220
overlays
code generation, compiler switch 219
files
loading into EMS 121
291
opening 120
manager, initializing. 120
Overlays Allowed
command 219, 220
option 219
OvrClearBuf procedure 116
OvrCodeList variable 116
OvrDebugPtr variable 117
OvrdosHandle variable 117
OvrEmsHandle variable 117
OvrFileMode variable 118
OvrGetBuf function 118
OvrGetRetry function 118
OvrHeapEnd variable 119
OvrHeapOrg variable 119
OvrHeapPtr variable 120
OvrHeapSize variable 120
OvrInit procedure 120
OvrInitEMS procedure 121
ovrIOError constant 125
OvrLoadCount variable 122
OvrLoadList variable 122
ovrNoEMSDriver constant 125
ovrNoEMSMemory constant 125
ovrNoMemory constant 125
ovrNotFound constant 125
ovrOk constant 125
OvrReadBuf variable 123
OvrResult variable 123
OvrSetBuf procedure 123
OvrSetRetry procedure 124
OvrTrapCount variable 125
ovrXXXX constants 125
p
$P compiler directive 218
PackTime procedure 125
pair matching 267
palette
color lookup table, returning size 77
definition record 63
PaletteType type 126
ParamCount function 126
parameters
command-line 59, 127
number of 126
292
number passed 59
ParamStr function 127
paste from Clipboard 267, 268
PathStr type 44
Pi function 127
PieSlice procedure 127
pixel values 77
place marker
find 267, 269
set 268, 270
PointType type 128
polygons, drawing 32
Pos function 128
Pred function 129
PrefixSeg variable 129
Printer unit, Lst variable 106
process-handling routines 99
Program Segment Prefix, address of 129
programs
execution, stopping 146
halting 85
rebuilding 231
Ptr function 129
PUBLIC definition errors 244
Putlmage procedure 130
PutPixel procedure 132
Q
/ Q command-line option 232
quiet mode command-line option 232
R
$R compiler directive 220
Random function 132
random generator
initialize 133
seed 133
random number 132
Randomize procedure 133
RandSeed variable 133
Range Checking
command 220
option 220
range checking 229
compiler switch 220
Val and 201
Programmer's Reference
read
a line 136
block 267
file component 135
records into a variable 13
t~xt file 133
Read procedure
text files 133
typed files 135
ReadKey function 135
Readln procedure 136
ReadOnly constant 43
Rectangle procedure 136
Red constant 22
Red text color constant 192
referencing errors 252
RegisterBGIdriver function 137
Register BGIfont function 139
registers, CS 26
Registers type 141
regular expressions
searching 270
wildcards 270
relaxed string parameter checking 222
relocatable reference .errors 244
RemoveDir procedure 141
Rename procedure 142
Reset procedure 142
resolution, graphics 59
RestoreCrtMode procedure 143
results, discarding 214
return flags for FileSplit constants 42
Rewrite procedure 144
RightText constant 99
RmDir procedure 145
Round function 145
run-time errors 257
,address of 39
fatal 261
Find Error command and 231
finding 231
generating 146
RunError procedure 146
5
$S compiler directive 221
SansSerifFont constant 55
Index
293
294
stack
checking switch directive 221
overflow, switch directive 221
size 218
Stack Checking
command 221
option 221
Str procedure 178
StrCat function 178
StrComp function 179
StrCopy function 179
StrDispose function 180
StrECopy function 180
StrEnd function 181
StrIComp function 181
strict string parameter checking 222
string
convert to 178
convert to number 201
first occurrence of 186
first occurrence of character in 187
last occurrence of character in 187
length of 1~O, 183
point to end of 181
String Var Checking
command 222
option 222
strings
allocating on heap 185
appending 178, 181
comparing 179
up to maximum length 182
without case sensitivity 181, 183
comparing up to maximum length 183
concatenation of 23
converting null-terminated 185
converting to lowercase 184
converting to uppercase 188
copying 179, 180, 186
copying characters 182, 184
deleting 27
disposing of 180
initializing 49
length byte 49
null-terminated 214
relaxed parameter checking of 222
strict parameter checking of 222
Programmer's Reference
T
IT command-line option 233
Tab mode 270
Tabs mode 268
TDateTime type in WinDos unit 189
technical support 2-4
terminating a program 40
cause of 41
with exit procedure 41
terminating program 85
Test8086 type in System unit 190
Test8087 variable 190
Index
295
types
file record 46, 195
mismatches, error messages 241
U
IU command-line option 234
$UNDEF compiler directive 222, 224
undo 268
unindent
block 267
mode 268, 270
Unit Directories option 234
units, version mismatch errors 246
UnpackTime procedure 200
untyped files, variable 13, 14
UpCase function 200
UserBitLn constant 102
UserCharSize constant 55
UserFill constant 49
V
IV command-line option 235
$V compiler directive 222
Val procedure 201
var, string checking, compiler switch 222
variable
decrementing a 27
environment 66
variables
disposing of 30, 56
DosError 39, 52, 66, 68, 160
dynamic, creating 74, 111
incrementing 89
untyped file 13, 14
VER70 symbol 225
VertDir constant 55
VGA
driver, modifying palette entries for 164
modes, emulated 91
VGAHi 69
VGALo 69
VGAMed 69
video mode constants 33
video operations
AssignCrt 10
CirEol21
296
ClrScr 21
DelLine procedure 28
GotoXY 81
HighVideo 88
InsLine 93
LowVideo 105
NormVideo 111
RestoreCrtMode 143
TextBackground 192
TextColor 193
WhereX202
WhereY 202
Window 203
Write (text) 204
Write (typed) 206
Writeln206
viewports 19
parameter 79
ViewPortType type 202
VMT, pointer to a 200
VolumeID constant 43
W
WhereX function 202
WhereY function 202
White constant 22
White text color constant 192
WideDotFill constant 49
WindMax and WindMin variables 203
WinDos unit
DiskFree function 30
DiskSize function 30
GetCBreak procedure 61
GetDate procedure 63
GetFAttr procedure 66
GetFTime procedure 68
GetIntVec procedure 71
GetTime procedure 78
GetVerify procedure 79
Intr procedure 97
MsDos procedure 110
PackTime procedure 125
SetCBreak procedure 155
SetFTime procedure 160
SetIntVec procedure 161
SetTime procedure 171
SetVerify 172
Programmer's Reference
x
$X compiler directive 214
XHatchFill constant 49
XORPut constant 13
y
$Y compiler directive 221
Yellow constant 22
Yellow text color constant 192
Z
Zenith Z-449, BGI and 91
Index
297
7.0
R L A N D
Corporate Headquarters: 1800 Green Hills Road , P.O. Box 660001 , Scotts Valley, CA 95067-0001 , (408) 438-8400. Offices in: Australia,
Belgium, Canada, Denmark, France, Germany, Hong Kong, Italy, Japan, Korea, Malaysia, Netherlands, New Zealand , Singapore, Spain,
Sweden, Taiwan, and United Kingdom Part #11 MN-TPL03-70 BOR 4681