Application module structure

User Rating: 5 / 5

Applications to TechEditor consist of modules. Let's consider the structure of a typical module of such an application.

When you create a new module in your application, the Application IDE creates a stub in the following format:

This template does not fulfill the full potential of the script. In general, an application module can contain:

• block of links to other modules
• block for defining global variables
• block for defining global constants
• procedure and function definition block
• execution unit

Each of these blocks is optional, but at least one of them must be present in the module.

Referring to other application modules

The block of references to other units begins with the word "uses" and is usually located at the very beginning of the unit:

uses  Unit1, Classes;beginend;

In this example, the module refers to the custom module Unit1 and the base (software) module Classes.

Reference modules are listed separated by commas.

Variable definition block

Module global variables are available throughout the application:

var
Diameter12: Double;  Notification: string;  x, y;

Note that TechEditor allows you to define a variable without explicitly specifying its type. However, from the point of view of clarity, this form of notation is not recommended.

Constant definition block

Module global constants are also available throughout the application:

const  PI = 3.14;  BOLT_D = 20;

Subroutine definition block

The subroutine definition block contains the code of procedures and functions that can be used in this module or in other application modules that refer to it. If Procedure A is used in Procedure B, then Procedure A must be described before Procedure B.

Example of a module with one subroutine:

function Rb: Double;begin  Result := 10.5;end;

Module execution

The execution block contains the code that will be executed immediately after the application is launched (provided that the application starts from this module). The commands are run sequentially, from top to bottom, left to right.

Typically, the execution block is placed between the begin..end statement brackets:

begin  ShowMessage('TechEditor is the best solution for engineer!');end;

However, a simplified record is also possible:

ShowMessage('TechEditor is the best solution for engineer!');

Repeating blocks

In TechEditor, a module can contain an unlimited number of blocks for defining variables and constants:

const  T = 'text';procedure Proc;beginend;var  a, b;function R: Integer;beginend;

However, from the point of view of code readability, it is recommended to place global variables and constants at the beginning of the unit, right after the "uses" block. It is also considered effective to move all the variables and constants of the application into a separate module.

New articles

Dystlab™ is a trademark registered in the State Register of Certificates of Ukraine for Goods and Services Marks 26.02.2018, certificate No. 238304. Owner: entepreneur Artomov V.E., EGRPOU/ITN: 3003314690.

E-mail:
technot needed texteditoranother not needed text@dystlabdummy text.store

Telegram:
https://t.me/techeditor