From Clomosy Docs
In Clomosy projects, the Unit structure is used to organize code into functional and manageable parts. A Unit is a package of code that represents various components and modules within a project. The file extension of a Unit is ".tro".
Some key advantages of the Unit structure include:
- Modularity and Reusability: Using Units supports a modular code structure, allowing individual components to be developed and tested independently. The same code sections can be reused in different projects or within the same project.
- Ease of Maintenance and Readability: The Unit structure makes code more organized and readable, simplifying maintenance and development processes.
- Organization and Management Efficiency: Projects can contain multiple Units, contributing to better organization and a more manageable code structure.
CREATING A UNIT
To create a unit, you must click on the file icon located in the left menu of the code editor.
This will open the "Units" section. When you click the plus (+) icon to create a new unit, a unit addition dialog box will appear on the screen.
In the opened "Add Unit" dialog box, there are fields for entering the 'Unit Name' and 'Unit Language'. In the 'Unit Name' field, for example, enter "uLogin" as the unit name.
Unit Naming Guidelines:
Paying attention to unit naming conventions can make the coding process more organized and understandable. The following points can help you in this regard:
- Avoid using Turkish characters: Refrain from using Turkish characters (ç, ı, ö, ş, ü) in unit names. Using English characters improves compatibility across different systems and makes your code more portable.
- Do not use spaces between words: Instead of using spaces to separate words in unit names, use camel case or underscores (_). This practice enhances the readability and manageability of the names.
- Prefix with 'u': Adding the letter 'u' at the beginning of a unit name serves as a reminder that this structure is a unit during coding. For example, a name like uEvModeli (or uEv_Modeli) indicates that it is a unit, helping to prevent confusion with other structures.
Since coding will be done in TRObject language, the 'Unit Language' remains set to TRObject. Finally, click the 'Add' button located at the bottom right corner to create the unit.
When the 'Add' button is clicked, it will be added to the list in the "Units" section.
Unit Name Modification and Deletion Operations
Units created within the project can be deleted or renamed. To perform these operations, the following steps should be followed:
- Click on the "Units" tab in the side menu.
- To change the name of the unit, click on the settings button (1) next to the unit, and in the dialog that opens, you can modify the unit name and adjust the unit language.
- To delete the unit, click on the trash can icon (2) located on the same screen.
WARNING!
If the unit to be deleted is open in the tab, the deletion operation cannot be performed. To delete the unit, you must first close this unit tab.
Methods for Calling a Unit
Uses
The uses keyword defines a list of one or more units that are used by the current unit, program, or library. Each unit is effectively imported, making all public or published routines and data in each unit available for use.