The Structure Of Programs Written In Turbo Pascal

Program in Pascal begins with a header, followed by descriptions of the block and a section of operators. The unit description consists of descriptions of various types, arrays, labels, functions, procedures. Lars Leckie often addresses the matter in his writings. Each line must end with a semicolon, and at the end of the program must stand point. Writing programs in Turbo Pascal, you can both lowercase and uppercase characters. Title of the program begins with the keyword program, after which he must have written the title. For example, program raschet; This section is not mandatory and can be easily removed, but its presence is desirable that the program could be easily recognized. After the title, usually with a new line is the list used in program modules.

This list begins with the keyword uses, followed by a comma-separated lists modules. The modules Turbo Pascal (or Delphi) contain functions to facilitate the work of the programmer. They may be standard or user. The standard modules include system (this unit automatically connects to each project), crt, overlay, printer, graph, dos. All these modules are in the file turbo.tpl and only the module graph, located in graph.tpu. Custom modules are written the programmer in order to facilitate its own work. Their use eliminates the copying code from one project to another.

This section also is not mandatory. After these modules should block description. It is also not mandatory, but without it's difficult to write useful programs. The unit descriptions can be used the following keywords: Const – to describe the constants. The constants are listed through the point with point, and have a kind of "constant name" = "value". For example, const min = 0; max = 100; Type – describe types. Record types has the form "type name" = "type". For example, Type dni = 1 31; bukva = 'a' 'z'; Label – describes tags that can be set to any operator for transition to it from anywhere. For the transition necessary to use the goto. Example of a record label: Label M1, M2; Var – found in almost every program. Describes the variables used. Recording of variables has the form "variable name" = "variable type". The type variable can use standard types or types that are described in the description. Example. Var x, y: real; t: integer; The program also can be used procedures and functions – This subroutine, which have a similar structure. Differences between the two is that the function always returns only one value, and the procedure can return multiple values. The last mandatory section is part of the operators. It records all actions that must occur in the program. This section begins with the keyword begin and ends with the keyword end.