## Application unit structure

User Rating: 5 / 5

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

When you create a new unit 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 unit can contain:

• block of links to other units
• 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 unit.

### Referring to other application units

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 unit refers to the custom unit Unit1 and the program unit Classes.

References in units separated by commas.

### Variable definition section

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 section

Global constants are also available throughout the application:

const  PI = 3.14;  BOLT_D = 20;

### Subroutine definition section

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

Example of unit with one subroutine:

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

### Unit execution

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

Typically, the execution section 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 sections

In TechEditor, unit can contain an unlimited number of sections 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.

### Events

Sorry, we currently have no events.

## New articles

Address in Canada: 223-2275 Lake Shore Boulevard West, Toronto, ON, M8V 3Y3

Address in Ukraine: 76006, Ivano-Frankivsk, st. Ivana Mykolaichuka 17/97

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

Telegram:
https://t.me/techeditor

### Legal information

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.