From Clomosy Docs
keyword Uses(Uses Unit1 {Unit2, ...};
The uses clause is defined to specify which other units a unit will use. This clause is important for the organization and reusability of code. In a Clomosy program, there can be multiple units, and the uses clause is used to organize the interactions between these units.
Each unit is imported effectively—making all public or published routines and data within that unit accessible.
Usage Example:
The uses clause is placed at the beginning of a unit, followed by the names of the other units to be used, separated by commas.
Main Code:
uses uLogin;
var
...
{
...
}
In the above example, the unit uLogin is used within the "Main Code." This allows access to the functions and properties of the uLogin unit within the "Main Code."
Importance:
The uses clause allows your code to be modular and keeps specific functionalities in separate modules. This helps make the code more organized, easier to maintain, and reusable. Additionally, when you want to use a specific function or component, you only need to add the relevant unit to the uses clause.
Example 1:
In the example, a procedure named "uCalculateTransaction" is defined in "MainCode" that takes two numbers, calculates their sum, and prints the result on the screen.
Main Code:
uses uCalculateTransaction;
var
value1, value2 : Integer;
{
value1 = 10;
value2 = 20;
uCalculateTransaction.AddNumbers(value1, value2);
}
uCalculateTransaction:
void AddNumbers(A, B: Integer);
var
Sum : Integer;
{
Sum = A + B;
ShowMessage('Total: '+ IntToStr(Sum));
}