


For example −įollowing are three important steps in creating a Pascal unit − The first line of this file should start with the keyword unit followed by the name of the unit. To create a unit, you need to write the modules or subprograms you want to store in it and save it in a file with. It is the same program we used right at the beginning of the Pascal tutorial, compile and run it to find the effects of the change. Writeln('Press any key when you are ready') Writeln('a, b, c are sides of the triangle') Writeln('This program calculates area of a triangle:') Gotoxy(30, 4) (* takes the pointer to the 4th line and 30th column) Textcolor(green) (* text color is green *) Textbackground(white) (* gives a white background *) The following example illustrates using the crt unit −
#FREE PASCAL CRT UNIT HOW TO#
However, let us first see how to include a built-in unit crt in your program − This tutorial explains creating and including user-defined units. We have already used the variants unit in Pascal - Variants tutorial. Using Built-in Unitsīoth the built-in units and user-defined units are included in a program by the uses clause. There are many built-in units in Pascal and Pascal allows programmers to define and write their own units to be used later in various programs. A unit might consist of some code blocks, which in turn are made up of variables and type declarations, statements, procedures, etc. A Pascal program can consist of modules called units.
