Foreword
About Pascal
Pascal is already far away from us and will be withdrawing from NOI support. In fact, OI has rarely used Pascal now, and the regular ones are C++. But Pascal is easier to learn and read, although the features provided by the standard are not rich.
About Turbo Pascal
Turbo Pascal was my first IDE, and it was quite old in the Windows age. Although there is Free Pascal now, its stability and compilation speed are not as good as TP. GNU Pascal has long since stopped updating, although it can be found, but it is quite difficult to use.
TP’s Chinese information is not rich, but bitsavers.org
there are a lot of documents on it, and you winworldpc
can get various versions of TP, which has become the basis of research. TP can be used under CP/M-80, CP/M-86 and DOS. I only study the version of DOS. After all, CP/M is more ancient. However, on my win64 platform, I can’t run a 16-bit TP at all, so I also need PCem – a PC emulator.
This article focuses on describing features, plus some images to avoid involving too much code. In addition, the first edition of this article can be [OLD]2017-04-09-Turbo-Pascal的历史.md
found in it.
Turbo Pascal and standard Pascal
Unsupported standard features
TP does not support some of the features of standard Pascal for some reason:
- The New procedure cannot be used for variant records and should use the standard procedure GetMem .
- The standard procedures Get and Put are not implemented because they can be replaced with Read and Write , and they are faster.
- The goto statement cannot leave the current block (current procedure, function, or main program).
- The standard procedure Page is not implemented because CP/M does not have a corresponding function.
- The keyword packed has no practical effect, because compression is automatic whenever possible; the standard process Pack and Unpack are not implemented.
- A procedure or function cannot be passed as a parameter.
new features
Absolute address variable
The keyword absolute can be used after the variable is defined to specify the address of the variable in memory.
1
2
3
4
|
var
Abc: Integer absolute $0000:$00EE;
Def: Integer absolute $0000:$00F0;
Special: array[l .. CodeSize] absolute CSeg:$05F3;
|
The first part of the address represents the segment address and the second part represents the offset address. The code segment is represented by CSeg and the data segment is represented by DSeg.
In addition, absolute can also specify a variable at the address of another.
1
2
3
|
var
Str: string[32];
StrLen: Byte absolute Str;
|
Bit/byte package
The keywords shl , shr, and xor represent left shift, right shift, and XOR, respectively, and are not defined in standard Pascal.
Direct access to memory and data ports
The arrays Mem and MemW are used to directly access the memory, and the address format is the same as the “absolute address variable”. The former type is Byte , the latter is Integer , and is represented by little endian. These two arrays can be read and written, just like regular arrays.
The array Port and PortW are used to access the data port of the 8086/88. Assignments and references to array elements can only be in expressions, and array elements cannot be passed as variable arguments.
Dynamic string
TP can use string to define dynamic strings up to 255 in length, and support + connection strings, direct assignments, and size comparisons. And define the Delete , Insert , Str , Val and other processes and Copy , Concat , Length , Pos and other functions. It is convenient to use than a character array, but has a length limit.
In addition, the string subscript 0 holds the Char type value corresponding to its length, and the length can be read by Ord and modified by Chr .
The definition part can be exchanged and repeated at will
Full support for operating system features
Related to the specific version, newer versions can directly call related procedures and functions, while older versions require manual calls to the operating system functions.
Insider code generation
Use the inline keyword to insert a piece of machine code that has free access to the registers, but you must ensure that BP, SP, DS, and SS are the same as they were entered before exiting.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
procedure UpperCase(var Strg: Str); {Str is type string[255] }
begin
inline
($C4/$BE/Strg/ { LES DI,Strg[BP] }
$26/$8A/$0D/ { MOV CL,FS:[DI] }
$FE/$Cl/ { INC CL }
$FE/$C9/ { L1: DEC CL }
$74/$13/ { JZ L2 }
$47/ { INC DI }
$26/$80/$3D/$61/ { CMP ES:BYTE PTR [DI], 'a' }
$72/$F5/ { JB L1 }
$26/$80/$3D/$7A/ { CMP FS:BYTE PTR [DI], 'z' }
$77/$EF/ { JA L1 }
$26/$80/$2D/$20/ { SUB FS:BYTE PTR [DI], 20H }
$EB/$E9); { JMP SHORT L1 }
{ L2: }
end;
|
Include file
TP allows another code comprising a code used {$I filename}
to achieve, if no extension is assumed to .PAS. The include file function #include
is roughly the same as the C preprocessor directive , but the TP does not allow nested include files.
Apply logical operators to integers
The logical operators not , and , or , xor can also be applied to integer types, ie bitwise negation, bitwise AND, bitwise OR, bitwise XOR.
Program chain that supports shared variables
TP provides the Chain and Execute procedures to call other programs. Chain can only call Chn-file
programs compiled with options with a .CHN extension. Such a file contains only the program code and does not contain the Pascal library. Execute can call any executable, but can’t pass arguments.
Use Chain to support sharing absolute and global variables, but special handling is required:
- Shared global variables must be defined at the beginning, and the order must be the same;
- The data segment and code segment must be the same when the program is compiled.
programMAIN.COM
1
2
3
4
5
6
7
8
9
|
program Main;
var
Txt:string[80];
CntPrg:file;
begin
Write('Enter any text: '); Readln(Txt);
Assign(CntPrg, 'ChrCount.chn' );
Chain(CntPrg);
end.
|
programCHRCOUNT.CHN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
program ChrCount;
var
Txt: string[80];
NoOfChar,
NoOfUpc,
I: Integer;
begin
NoOfUpc := 0;
NoOfChar := Length(Txt);
for I := 1 to Iength(Txt) do
if Txt[I] in ['A' .. 'Z'] then NoOfUpc := Succ(NoOfUpc);
Write( 'No of characters in entry: ',NoOfChar);
Writeln( '. No of upper case characters: ', NoOfUpc,'.');
end.
|
Random access data file
Use Seek (FilVar, n) to move the file pointer to the nth record, starting with 0.
Structured constant
Constants can specify types, including unstructured types and arrays, multidimensional arrays, records, collections, and more.
Type conversion function
A cast function can be used, but floating point numbers are not supported.
New dynamic memory allocation
TP1 introduced Mark and Release instead of Dispose . Mark (Var) saves the heap pointer to Var , and Release (Var) assigns the heap pointer to Var . This Release will free up all the space from Var and is more efficient than New/Delete .

Version comparison
1.0 (1983)



Official introduction

Official download: http://altd.embarcadero.com/download/museum/tp1.zip
Release date: 1983/11/20
Price: $49.95+$5$ shipping
System Requirements
- Intel 8086 and Zilog Z-80 microprocessor
- 64KB memory
- For CP/M and DOS systems, 51⁄4″ floppy disk
- For CP/M systems, 8″ floppy disk
File List
TP1.0 is released on a single floppy disk with a total of 10 files, 131,297 bytes. TURBO.COM (which includes an IDE with a compiler, a Wordstar-style editor, and a system running in memory) is 33,280 bytes in size.
- TURBO.COM – compiler and editor
- TURBOMSG.OVR – error message file
- TINST.COM – IDE installer
- TINSTMSG.OVR – Error message for TINST program
- TLIST.COM – Print program
- ERROR.DOC – manual additional content
- CALC.PAS – MicroCalc Table Sample Program
- CALCMAIN.PAS – Sample contains features
- CALC.HLP – MicroCalc Help Manual
- CALCDEMO.MCS – Sample table definition
use
TP1 does not support directory operations, only the current directory. There is also an unimplemented running function. Input X indicates that the function is not implemented on the 8086/88 and only supports CP/M-80.
In fact, the TP2 manual Appendix P is the TP1 manual. It is said that TP2 directly provides the TP1 manual plus Appendix P.
See TP2 for the use of the user interface.
External subroutine
An external subroutine can be declared in TP with external , which must be relocatable.
1
2
|
procedure Plot(X,Y: Integer); external 'PLOT';
procedure QuickSort(var List: PartNo); external 'QS';
|
DOS function call
In the early TP, there was no direct DOS interface, and the DOS function was called using the MsDos procedure. The following code provides a way to get time, which can be placed in an include file. For other function calls, see the DOS Reference Manual or use the newer TP.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
type
regfile=record
AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags:integer;
end;
timeRec=record
h,m,s,s100:integer;
end;
procedure getTime(var t:timeRec);
var
reg:regfile;
begin
reg.AX:=$2C shl 8;
MsDos(reg);
t.h:=reg.CX shr 8;
t.m:=reg.CX and 255;
t.s:=reg.DX shr 8;
t.s100:=reg.DX and 255;
end;
|
2.0 (1984)



use
Although not mentioned in the manual, the user interface can already switch directories.
The user interface is weird, but it can still be used. In the main menu, press the highlighted letter to select the corresponding function. If you want to open or create a new file, you need to:
- L switches to the required drive
- A change the current directory
- W input file name
- E enters edit mode
- ^KD exit edit mode
- S save
- C compilation
- R running
ART.PAS
The following are the effects of running ART.PAS:

Note that by default, TP2 compiles the program into memory so it can be run directly. If you need to generate an executable, you need to modify the compile option to Com-file. The ART.COM generated by compiling ART.PAS has only 11,518 bytes.
a recursive test
Edit mode has no code highlighting feature. By default, the 8,127 layers are recursively, then the runtime error FF is given and the PC is given. If compiled into memory, the RE location is automatically located.
If you compile to a file, just record the PC and select F in the options.
Of course, TP2 has no debugging function, only the function of finding the RE location.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
program recursion;
var
maxdep:integer;
procedure recur(x:integer);
begin
if x<=maxdep then
begin
writeln(x);
recur(x+1);
end;
end;
begin
writeln('hello, world');
read(maxdep);
recur(1);
end.
|
Overlay function ( overlay )
The overlay function can load multiple function modules of a program into the same location in memory to expand the size of the program. Just add the overlay keyword before the procedure or function declaration .
Override functions or procedures in the same region cannot be called from each other, nor can they be forward-defined, and cannot be called recursively. In short, at one moment, only one overlay function or process can be run within a coverage group.
Note that the overlay file is saved on disk, so frequent call coverage will reduce efficiency and should be weighed against this feature. The following illustrations are used to visualize the understanding.



Additional features of the IBM PC
Allows you to switch text/graphic modes, set colors, draw windows, and use advanced features such as sound. It is not detailed here, you can refer to the sample program.
Turbo-87 Pascal
This version of TP2 could not be found. According to the documentation, this version must have a 8087 floating-point coprocessor to use, and replace the default (in fact double
) with a 64-bit real number , with higher precision and faster speed.
3.0 (1985~1986)



Official introduction (3.02)
Official download: http://altd.embarcadero.com/download/museum/tp302.zip
Release date: 1986/9/17
Price: (including 8087 and BCD); CP/M-80 version (excluding 8087 and BCD):
System Requirements
16-bit system
- 128KB of memory (including 8087 and BCD)
- MS-DOS 2.0 and CP/M-86 1.1
8-bit system
- 48KB memory (not including 8087 and BCD)
- CP/M-80 2.2
file
The TP3 file is slightly larger than 2.0. I found the version with BCD and 8087, TURBOBCD.COM and TURBO-87.COM.
Speed improvement
Both 2.0 and 3.0 provide a large example of CALC.PAS with 30+KB. Below is an estimate comparison (IBM AT 286/6):
|
Load time |
Compile to memory |
Compile to file |
2.0 |
2s |
8s |
10s |
3.0 |
<1s |
4s |
4s |
It can be seen that there are many improvements.
Turtle Graphics
The turtle graphic is based on the concept of “turtle”, which can move a specific distance to a specific angle and draw a graphic. Turtle graphics need to be manipulated in the window. See the sample TURTLE.PAS. Note that there should be GRAPH.P and GRAPH.BIN files in the same directory at compile time.

Directory operation
Provides ChDir , MkDir , RmDir and GetDir to implement the relevant directory operations, process and DOS, like the first three, GetDir (Drive, Str) Gets Drive current directory to Str . Drive is an integer, 0 means the current directory, 1 means A, … can refer to DIRECT.PAS.
Get command line arguments
ParamCount and ParamStr are provided to get the command line arguments, which is the same as C’s argc and argv . See the example CMDLIN.PAS.
Turbo-BCD
Turbo-BCD uses BCD to store floating point numbers to avoid decimal errors. For example, decimal 0.1 is not accurately represented in binary, but can be accurately represented in decimal floating point numbers (BCD).
Turbo-BCD cannot use Sin , Cos , ArcTan , Ln , Exp , Sqrt, and Pi . Pascal programs that do not contain these identifiers can be compiled with Turbo-BCD. The range of BCD floating point numbers is $\vert R\vert\in10^{-63}\dots10^{63}$, the effective digit is 18 bits, occupying 10 bytes of space. BCD floating point numbers can be formatted using the Formfunction, see the manual.
BCD.PAS can be used to demonstrate the advantages of Turbo-BCD. The result of compiling with TURBO.COM:

Use TURBOBCD.COM:


Turbo-87
As with 2.0, the 8087 coprocessor is also required. I ran on an IBM AT (286) without x87 and the result was an invalid floating point number. Therefore, it must be tested on a PC with a math coprocessor. Since PCem does not have a separate analog x87 switch, I used 486DX, which is the earliest built-in x87 CPU.
Demonstrating Turbo-87 with HILB.PAS and TEST.PAS, below using TEST.PAS, you can compare speed and accuracy. I included the timing library TIMER.PAS I wrote myself. Use TURBO.COM:

Use TURBO-87.COM:


The result of using the following code is 1.644903548804433, which is basically the same as Turbo-87:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <iostream>
#include <limits>
using namespace std;
int main()
{
int n;
cin >> n;
double ans = .0;
for (int i = 1; i <= n; i++)
ans += 1.0 / (i * i);
cout.precision(numeric_limits<double>::digits10);
cout << fixed << ans << endl;
return 0;
}
|
4.0 (1987)


file
I found three versions of the 360KB floppy disk. It is best to copy all the files to the same directory. It can be found that the executable has been changed from .COM to .EXE. Here are some important files:
- TURBO.EXE: Provide IDE, 115KB
- TURBO.TPL: Standard unit, 37KB
- GRAPH.TPU: Graph unit, 27KB
- TPC.EXE: Command Line Compiler, 42KB
- MAKE.EXE: Automatically update the modified program, 19KB
use
The TP4 already has a menu and looks much better than the previous versions. But the Output window is annoying, press F5 to turn it off. Switch to the menu can use Alt + highlight letters, you can also use F10, it is better to use F10 in PCem, because the former will also trigger the PCem menu. Press ESC to return to the editing window.
ARTY4.PAS
ART.PAS has also been upgraded!


ARTY4.EXE compiled to file generation has 24,384 bytes, which is much larger than 2.0.
Upgrade early programs
UPGRADE.EXE is used to do this. I tried it with 3.0 CALC.PAS and the original file was renamed to CALC.3TP. However, the compiled file is also used for 4s, without the speed increase mentioned in the manual. However, the MicroCalc provided by MCALC.PAS is much more advanced than before. Not only did the color increase, but it was compiled again very quickly because MAKE.EXE was used.


Code generation optimization
I also upgraded TEST8087.PAS and TIMER.PAS, rewritten with the GetTime of the Dos unit , and renamed my GetTimeto myGetTime , which is fine . Of course, I am going to write TIMER.PAS in a unit format.
Running with 32767, not using 8087, 3.0 using 42s, 4.0 using 32.5s, the improvement is still very obvious.
Unit and Make
The unit is the biggest improvement in 4.0, and various interfaces are available in the unit. This allows you to divide a large program into units, which can be written and debugged separately, and finally connected into the final program. When only modifying some files, use the Make function, you only need to recompile the modified part and then connect. The Build function recompiles all the files.
The structure of the unit is as follows:
1
2
3
4
5
6
7
8
9
10
|
unit unitname;
interface
{ uses <list of units>; Optional}
{ public declarations }
implementation
{ private declarations }
{ procedures and functions}
begin
{ initialization code}
end.
|
In fact, according to the above structure, the unit is similar to the header file and the implementation file in C. Wherein the interface to the implementation part similar between the headers, the implementation part after implementing the interface.
The various interfaces provided by TP are also provided through the unit, using uses to include other units. Among them, TURBO.TPL includes System , Crt , Dos , Printer , Turbo3 and Graph3 , and GRAPH.TPU contains Graph unit.
- The System unit contains the basic Pascal procedures and functions, each of which contains the System unit by default .
- Dos unit provides most of the DOS API calls, such as GetTime , SetTime , DiskSize , but also provides the old MsDosand Intr .
- The Crt unit provides text interface control and sound control.
- The Printer unit provides Lst files to support the printer.
- The Graph3 unit provides all the graphics features in 3.0.
- The Graph unit provides more faster and more powerful graphics features, including my VGA and earlier CGA, EGA and Hercules.
Because of the unit, the program chain and overlay functions are no longer supported and should be converted to units.
Include nesting of files
Previous versions contain files that cannot be nested, and TP4 can be nested no more than 8 layers.
New data type
TP4 provides new integer types longint , shortint , word , and if you have an x87 coprocessor, you can also use single , double , extended , and comp . Prior to this, TP only provided 16-bit integers, and now you can use up to 64-bit integers (ie, comp ).
64-bit integer comp in TP : Many OIers who have used Pascal do not know that TP also has 64-bit integers. The range of comp is $-2^{63}+1\dots2^{63}-1$. Although comp is a floating point type, it can only hold integers and is 1 different from a standard 64-bit integer. Comp requires the x87 coprocessor to use.
To use x87, you must turn on the compile switch {$N+}
, which is by default ${N-}
. When this mode is turned on, all floating point operations are performed with extended precision, and the default output format is also changed to extended format. If there is no x87, TP does not allow compiled ${N+}
programs.
In addition, the 8087 uses its own arithmetic stack, so the procedures and functions for writing x87 should pay special attention. For example, the following function will cause the 8087 stack to overflow:
1
2
3
4
5
6
|
function Fib(N: integer): extended;
begin
if N = 0 then Fib := 0.0 else
if N = 1 then Fib := 1.0 else
Fib := Fib(N-1) + Fib(N-2);
end;
|
The correct way to write is to save the Fib(N-1)
sum with temporary variables Fib(N-2)
. Refer to FIB8087.PAS.
Short-circuit Boolean expression evaluation
Boolean expressions are short-circuited by default, but can be changed by compiling the switch.
Conditional compilation
Provides compile instructions {$DEFINE name}
, {$UNDEF name}
, {$IFDEF name}
, {$IFNDEF name}
, {$IFOPT switch}
(judge compile switches) {$ELSE}
, {$ENDIF}
to implement conditional compilation, similar to C preprocessor directives. In addition, if there are x87, it will define the CPU 87 .
Command line compiler
TPC.EXE is a command line compiler that is also very simple to use, such as TPC QSORT.PAS
compiling QSORT.PAS to QSORT.EXE. Commonly used options include /M(Make), /B(Build), /Q(Quiet), /F(Find), /R (running in memory), /X (running), where /F is equivalent to the previous “Find runtime error” feature.
5.0 (1988)


installation
This is the first version that needs to be installed. I am using two versions of 720KB floppy disk. INSTALL.EXE is used for installation. The installation process not only includes copying files, but also decompressing .ARC, so it is best to use the installer.

use
The user interface is quite different from 4.0, blue accounts for most of the area, and the menu is more abundant. However, Load and Save are not displayed in the shortcut list, but they are still available. Now Output is displayed in full screen with the classic shortcut Alt+F5. Compared to 4.0, the debugging function is mainly added. In addition, the available memory displayed when running MicroCalc has increased a lot (all running in memory).

Source code level debugging
TP5 finally supports basic debugging features in the IDE, and it is easy to use. The following routines are provided in the user manual:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
{$D+,L+} { Just to be sure complete debug information is being generated }
{$R-} { Just to be sure range-checking is off }
program RangeTest;
var
List : array[1 .. 10] of integer;
Indx : integer;
begin
for Indx := 1 to 10 do
List[Indx] := Indx;
Indx := 0;
while (Indx < 11) do
begin
Indx := Indx + 1;
if List[Indx] > 0 then
List[Indx] := -List [Indx]
end;
for Indx := 1 to 10 do
Writeln(List[Indx])
end.
|
This program is an infinite loop, the reason is not clear: because the position of List[11] is Indx, so the next set Indx to -11, resulting in an infinite loop. However, if you don’t know the memory allocation mechanism of the TP, it may be difficult to think of this error.
With the debugging feature, it is easy to find this problem. This will add List and Indx to Watch, then F8 will step through. When Indx=11, it shows the above behavior. What if I open the range check ( {$R+}
)? Stop debugging before modifying, ie Run-Program reset. At this time, I reported error 201. I believe everyone is familiar with it. However, it should be noted that TP5 does not enable range checking by default, you need to manually change the option or add a compile switch {$R+}
.
Complete 8087 floating point simulation
The compile switch {$E+}
is turned on by default to allow software to emulate 8087 floating-point operations, so programs can use x87 instructions on PCs with x87 and software emulation on PCs without coprocessors.
Cell-based coverage
After the traditional overlay function was abandoned by 4.0, 5.0 introduced a cell-based overlay function that directly used the unit as the overlay content. A compile switch is ${O+}
needed to allow a unit to use the override function, ${F+}
forcing all calls to be FAR. As long as the above two compile switches are added ${F+}
to the unit that needs to be covered, it can be added in the main program .
In the main program must contain Overlay cells, followed by {$O unitname}
cell designated to cover. The main program should also use OvrInit to initialize the overlay file and, if possible, use OvrInitEMS to load the overlay file into the EMS. In addition, there is an OvrResult like IOResult to detect errors. Programs that include overrides can only be compiled to a file. Refer to OVRDEMO.PAS.
EMS extended memory
Let me explain what EMS is. In the 8086/8088, the addressing space is $2^{20}$=1MB, with a lower 640KB that can be accessed directly by the program (conventional memory) and the remaining 384KB for hardware. In the IBM AT/286 era, although the addressing space reached 16MB, it only supports access in protected mode, and no DOS program can run there.
One of the solutions at the time was the memory disk. I believe everyone should be familiar, but the memory disk cannot be used to run programs. Another way is to expand the memory and use a portion of 384KB as a “window” to use the high memory area. One of them is the Lotus/Intel/Microsoft Expanded Memory Specification (EMS). The TP5 supports the 3.2+ version. The extended file can store the overlay file and use the extended memory for the built-in code editor. EMS.PAS can be used to detect if EMS is available.
Process type
A procedure type can define a procedure or function as a variable and pass it as a parameter.
1
2
3
4
5
6
7
|
type
Proc = procedure;
SwapProc = procedure(var X,Y: integer);
StrProc = procedure(S: string);
MathFunc = function(X: real): real;
DeviceFunc = function(var F: text): integer;
MaxFunc = function(A,B: real; F: MathFunc): real;
|
Of course, TP does not allow returning process types, nor does it allow standard procedures or functions, nested procedures or functions, inline procedures or functions, interrupt procedures, or functions to be assigned to procedure types. In addition, you need to turn on the compile switch {$F+}
. Refer to PROCVAR.PAS.
Constant expression
TP5 allows constants to be initialized with expressions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
const
Min = 0;
Max = 100;
Center = (Max - Min) div 2;
Beta = Chr(225);
NumChars = Ord('Z') - Ord('A') + 1;
Message = 'Out of memory';
ErrStr =' Error: ' + Message + '. ';
ErrPos = 80 - Length(ErrorStr) div 2;
Ln10 = 2.302585092994045684;
Ln10R = 1 / Ln10j
Numeric = ['0' .. '9'];
Alpha = ['A' .. 'Z' ,'a' .. 'z'];
AlphaNum = Alpha + Numeric;
|
5.5 (1989)



Official introduction

Official download: http://altd.embarcadero.com/download/museum/tp55.zip
Release date: 1989/5/2
TOUR
5.5 includes a TOUR.EXE – an online introduction tool that allows novices to understand the use of the IDE, which takes about 15 minutes to complete.

Object oriented
5.5 The main improvement is the full support for object-oriented programming (OOP), of course, TP mainly borrows C++. In fact, from a certain point of view, the object is a record with procedures and functions, in the TP with the keyword object instead of record .
Class definition
1
2
3
4
5
6
7
|
type
Location = object
X, Y : Integer;
end;
Point = object(Location)
Visible : Boolean;
end;
|
The parentheses indicate the inheritance relationship. In the Point class, X and Y can be used normally .
Method definition
1
2
3
4
5
6
7
8
9
10
|
type
Location = object
X, Y : Integer;
procedure Init(NewX, NewY : Integer);
end;
procedure Location. Init (NewX, NewY : Integer);
begin
X := NewX; { The X field of a Location object }
Y := NewY; { The Y field of a Location object }
end;
|
Class-owned procedures and functions are called methods . Unlike C++::, TP directly uses methods that represent classes. In addition, the TP has no access control and cannot prevent direct access to the fields of the class. Fields must be defined before all methods.
Self use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
type
MouseStat = record
Active: Boolean;
X, Y : Integer;
LButton, RButton : Boolean;
Visible : Boolean;
end;
procedure Location.GoToMouse(MousePos : MouseStat);
begin
Hide;
with MousePos do
begin
Self.X := X;
Self.Y := Y;
end;
Show;
end;
|
The above code shows the usage of Self , which is similar to this , except that the latter is a pointer.
Method overload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
type
Circle = Object(Point)
Radius : Integer;
procedure Init(InitX, InitY : Integer; InitRadius : Integer);
procedure Show;
procedure Hide;
procedure Expand(ExpandBy : Integer);
procedure MoveTo(NewX, NewY : Integer);
procedure Contract (ContractBy : Integer);
and;
procedure Circle.Init(InitX, InitY : Integer; InitRadius : Integer);
begin
Point.Init(InitX, InitY);
Radius := InitRadius;
and;
procedure Circle. Show;
begin
Visible := True;
Graph.Circle(X, Y, Radius);
and;
procedure Circle. Hide;
var
TempColor : Word;
begin
TempColor := Graph.GetColor;
Graph.SetColor(GetBkColor);
Visible := False;
Graph.Circle(X, Y, Radius);
Graph.SetColor(TempColor);
end;
procedure Circle.Expand(ExpandBy : Integer);
begin
Hide;
Radius := Radius + ExpandBy;
if Radius < 0 then Radius := 0;
Show;
end;
procedure Circle. Contract (ContractBy : Integer);
begin
Expand(-ContractBy);
end;
procedure Circle.MoveTo(NewX, NewY : Integer);
begin
Hide;
X := NewX;
Y := NewY;
Show;
end;
|
The overloaded method simply defines the exact same method and changes the content. In the above example, Point.Init is used to call the Point method.
Construction and destruction
TP uses the keyword constructor to decorate the construction process, and destructor to decorate the destructor process. It is recommended to name it Init and Done .
1
2
3
4
5
6
7
8
9
10
11
|
Point = object(Location)
Visible : Boolean;
Next : PointPtr;
constructor Init(InitX, InitY : Integer);
destructor Done; virtual;
procedure Show; virtual;
procedure Hide; virtual;
function IsVisible : Boolean;
procedure MoveTo(NewX, NewY : Integer);
procedure Drag (DragBy : Integer); virtual;
end;
|
Virtual method
TP also supports virtual methods. After using the virtual keyword in the method definition, it will not be described in detail here. You can refer to C++.
Object-oriented Calc
The historic MicroCalc has been renamed to TurboCalc and is rewritten with object-oriented.

Object debugging
5.5 also supports debugging of objects.
Improvement of coverage function
Overwrite buffer management
In 5.0, the overlay buffer is maintained with a data structure similar to a circular queue, loaded directly when space is sufficient, and the oldest module is deleted when not enough. However, 5.5 provides an alternative algorithm: when a module’s space to the end of the queue is less than the threshold, the module is marked. If the marked module is subsequently called, the module is used frequently and moved to the head of the team. Through testing, you can get the best threshold and implement it with the interface provided by 5.5.
Put the overlay file into the .EXE file
TP5.5 supports placing overlay files in .EXE to reduce the number of files. You must first make sure to turn off the debug symbols and then use the COPY command with the /B option, for example COPY /B MYPROG.EXE + MYPROG.OVR
. Loading the overlay file with an .EXE file, ieOvrlnit(ParamStr(0));
6.0 (1990)



IDE

The new IDE supports multi-window editing and supports window overlays, side-by-side alignment, etc. (Windows 2.0). Support for the mouse, but I installed CuteMouse myself.
Turbo Vision

Turbo Vision is an object-oriented application framework for developing graphical interface programs in the same style as IDEs. Of course, it is actually based on the text interface, but provides the implementation of windows, menus, status bars, dialog boxes and other elements. The above picture is an example. The disadvantage is that it is very memory intensive, and the number displayed in the lower right corner is the available memory. The available space should be increased when running outside the IDE.

After exiting the IDE, you can freely open the file, but you can only view it and you cannot modify it. Four tools are also available: 15 digital, calendar, ASCII table and calculator.


There is also a smart help function, just press F1.

Inline assembler
This feature allows you to insert 80(2)86/7 assembly code directly into Pascal code, although the old method can still be used. It supports a significant portion of the grammar subset of Turbo Assembler, but does not support most of the compile instructions, and should be replaced with Pascal syntax.
By asm used inline assembler statement.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
asm
mov ah,0 { Read keyboard function code }
int 16H { Call PC BIOS to read key }
mov CharCode,al { Save ASCII code }
mov ScanCode,ah { Save scan code }
end;
asm
push ds { Save DS }
lds si,Source { Load source pointer }
les di,Dest { Load destination pointer }
mov cx,Count { Load block size }
cld { Move forwards }
rep movsb { Copy block }
pop ds { Restore DS }
end;
|
Inline compiled keywords
1
2
3
4
5
6
7
8
9
10
11
|
AH CL FAR SEG
AL CS HIGH SHL
AND CX LOW SHR
AX DH MOD SI
BH DI NEAR SP
BL DL NOT SS
BP DS OFFSET ST
BX DWORD OR TBYTE
BYTE DX PTR TYPE
CH ES QWORD WORD
XOR
|
Object-oriented improvement
Private brings in private fields and methods, which were not supported in the previous version. However, unlike the class in C++ , the default is still public (of course without this keyword), similar to struct (POD).
1
2
3
4
5
6
7
8
|
type
NewObject = object(ancestor)
fields; { these are public }
methods; { these are public }
private
fields; { these are private }
methods; { these are private }
end;
|
Extended grammar
The extended syntax switch ( $X
) can use a function like a procedure, ignoring its return value.
286 code generation
Using a $G
switch allows for the generation of 286 code, which cannot run on the 8086.
TPTOUR
This version of TOUR is much more advanced than 5.5, and it is a bit like the Windows 3.1 tutorial on mouse usage. However, this tutorial is biased towards using a keyboard instead of a mouse, and sometimes there are warnings: use the keyboard instead of the mouse.




7.0 (1992)


IDE
In addition to the traditional real mode (8086) TURBO.EXE, TPX.EXE is also provided in protected mode. To run the IDE in protected mode, you must have 286 and at least 2MB of memory.
There are some differences between the two IDEs, the memory usage is different, and TPX no longer provides compile to memory functions, only compile to files.


Syntax highlighting
7.0 supports default keyword highlighting in white, annotations in gray, assembly in green, and rest symbols in yellow. Of course, this setting can be manually modified in the menu, and can be modified to be close to the Free Pascal highlight, but does not recognize the compile switch.

Undo function
Undo and restore functionality, same as modern editors, can be persisted…
Right click menu
This is also very basic in the present…
Language improvement
Variable length parameter
Support variable length string OpenString and variable length array parameters (note that only parameters), use Lowand High to return the starting subscript and end subscript, equivalent to the C++ container begin and end methods, but not the end.
Object oriented
Provides a public keyword that can be mixed with private . In addition, the inherited keyword can call the ancestor’s method.
Const parameter
The argument to const cannot be modified, equivalent to a constant.
Runtime library (RTL)
New system function
- Assigned : Test whether the pointer is nil
- Break
- Continue
- High
- Low
Leave a Reply