From Clomosy Docs
Clomosy.RunUnit(unitName: String);
It is a method used to run or redirect to a specific unit. This allows for the dynamic loading and utilization of units.
Its purpose is to activate the functionality of a specific unit and to interact with that unit. By running the unit, the code, functions, and procedures within it become accessible.
It is typically called in response to user interactions or specific events to open or execute units. For example, a unit can be run when a user clicks a button.
If you are new to using the RunUnit feature, try the application shown in Example 1.
Example 1
In this example, it is necessary to create a new unit when using the RunUnit feature. Before using the example code, a unit named "uLogin" should be created in your application. Otherwise, an error will occur.
Main Code:
Clomosy.RunUnit('uLogin');
uLogin:
ShowMessage('Hello, you have been redirected from the main code to the uLogin unit.');
Example 2
In the example above, the "uLogin" unit was created. In this example, components have been added to both the "Main Code" and "uLogin" pages. Here, when a button in the "Main Code" is pressed, it navigates to the "uLogin" unit, and when the page within this unit is clicked, it returns to the "Main Code" page.
Main Code:
var
Form1:TCLForm;
buton1 : TclButton;
void goToLogin;
{
Clomosy.RunUnit('uLogin');
}
{
Form1 = TCLForm.Create(Self);
buton1 = Form1.AddNewButton(Form1,'buton1','Go to uLogin');
buton1.Width = 150;
Form1.AddNewEvent(buton1,tbeOnClick,'goToLogin');
Form1.Run;
}
uLogin:
var
formLogin:TCLForm;
btnLogin : TclButton;
void goToMainCode;
{
formLogin.clHide;
}
{
formLogin = TCLForm.Create(Self);
btnLogin = formLogin.AddNewButton(formLogin,'btnLogin','Go to Main Code');
btnLogin.Width = 150;
formLogin.AddNewEvent(btnLogin,tbeOnClick,'goToMainCode');
formLogin.Run;
}
When redirecting to the "Main Code" using RunUnit from a unit, it must be called as "Main".
Example
Unit: uLogin
var
...
{
...
Clomosy.RunUnit('Main');
}