Last Updated:

Custom modules in Pascal

Custom modules in Pascal

Despite the fact that the Pascal programming language has always been considered a tool through which you can implement the process of creating simple and understandable programs, you can also use it to create structured programming technologies. For this purpose, special modules are used that act as subroutines.

All libraries textually carry out the process of combining into program units that are independent. In the future, they are called modules of the Pascal programming language. They are created in order to obtain subroutine libraries.

Often, it is the modules that carry out the procedure for combining those subprograms that are engaged in the process of implementing those tasks that belong to the same class.

Structural features of the modules in Pascal

Through functions and procedures, the module carries out the process of providing tools with the support of variables, constants and certain types of data. But if we consider the actual process of implementing such funds, then it is almost completely hidden. This is due to the fact that conditionally the module can be divided into several sections:

  • realization
  • interface.

In the event that the program carries out the process of using the module, then it automatically gets access to all its descriptions.

If we consider the structural features of the module, they are almost identical to the structure of the program. But at the same time, it is possible to distinguish some significant distinctive features. For example, you can pay attention to the module of the following sample:


If you look at the module header, it starts with a special reserved unit. Immediately after it is an identifier that acts as the name of the module. This element is exactly the same as with an ordinary program. After that, the following keyword interface is mandatory in the module. It indicates that the section responsible for the interface begins in the module. It will be visible to absolutely all programs that will use it.

It is worth paying attention to the fact that other modules can be used in one module. In order to implement this process, it is necessary to implement them in a sentence with the word uses. Often it is immediately located after the word interface. The rule by which the uses clause is used is standard. In the event that other modules will be used in one module, then they must be specified immediately before they are executed.

Variants of standard modules in Pascal


It is worth paying attention to the fact that the Pascal programming language uses a huge number of modules, among which we can distinguish those that belong to the category of standard.

Turbo – the presented file includes absolutely all packages in addition to the compatibility pack and Graph. Their process of loading into memory occurs immediately with Pascal and is always freely available. Often, the process of storing this file takes place in one directory, but it is possible to implement such an action as storage, and in a completely different directory that is needed.

At the same time, it must necessarily be described as a catalog that is part of the Turbo-Pascal structure. If there is a need to implement this, you need to perform the process of installing the Tinst.exe directory in the Turbo file.exe.

System – this module includes all the built-in and standard turbo-Pascal functions and procedures. This necessarily includes absolutely any subprogram that is not part of any of the modules and is not an integral part of Pascal. You can attach the presented type of module to any desired program.

DOS – used to implement the definition of various Pascal functions and procedures, but only those that are complete equivalents of those used in DOS calls. In addition, by using this module, it is possible to perform the process of identifying Intr and MsDos programs that are at a fairly low level.

With their help, you can perform a system interrupt if necessary, or activate any necessary DOS call. You can also use this kind of module to implement a process such as defining certain data types and constants.

Overlay – this module includes tools through the use of which you can carry out the process of creating various overlay programs. At the same time, it is worth paying attention to the fact that the process of downloading such a program in the future will not be performed completely, but in parts.

Crt – due to the use of this module, it is possible to implement a process such as the description of variables, constants and programs used for input and output, having a specific form. At the same time, as for programs, in the future they can be actively used in the process of working with the screen (background color, text, work with the cursor, windows, etc.).

It is also possible to perform input from the keyboard "raw look", as well as to implement the process of controlling the board, which performs the generation of an audio signal. Through the use of this module, it is possible to ensure the functioning of a huge number of subroutines.

Printer – the structure of the presented module necessarily includes a description of the variable that works with the text file. It is this variable that performs the procedure for interacting with drivers in a certain way, which redirect certain commands to the printing device being used.

Graph3 – this module provides the process of supporting absolutely any subroutines working with graphic elements. It can be used for both ordinary and extended graphics.

Turbo3 - the presented module includes several procedures and variables, the support of which can no longer be implemented through the use of Turbo-Pascal. This includes a mandatory boolean operation, a file variable and integer versions of MaxAvail and MemAvail, which allow you to perform the process of returning free memory in paragraphs. If we consider modern versions, they perform this process in bytes, which is not always convenient.

Graph – a module that is responsible for providing efficient and fast-acting graphics-type subroutines. In the future, this is convenient because it makes it possible to use absolutely all the graphic capabilities that a personal computer has. With the help of the presented module, you can implement a graphics driver that does not depend on a specific device.

Features of creating your own module


In the event that the programmer has implemented such a process as writing his own module, in order for it to be actively used in the future, such a component as uses must be built into it. It is he who will tell the compiler which of the modules he will have to use in the process of work. For example, the program may be represented in the following form:


It is worth paying attention to the fact that Turbo-Pascal himself believes that the module itself and the file in which it is placed should have identical names. Therefore, in the event that the module will have the name МyUtilities, then Turbo-Pascal will carry out the process of searching for a file with this name.

As for such a process as compiling a module, it is exactly the same as compiling a program. The creation process is carried out by using a special editor, after which the command used to compile the module is called. Do not forget that one module can be located only in one source file and no more than it could be done earlier.