From Clomosy Docs

(Created page with "<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> Clomosy.RunUnit(unitName: String); </div> It is a method used to run or redirect to a specific unit. This allows for the dynamic loading and utilization of units.<br> 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.<br> It is typica...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 70: Line 70:
}
}
</pre>
</pre>
<div class="alert alert-success" role="alert" data-bs-theme="light">
When redirecting to the "Main Code" using RunUnit from a unit, it must be called as "Main".<br>
<b> Example </b><br>
<i> Unit: uLogin</i>
<pre>
var
...
{
...
Clomosy.RunUnit('Main');
}
</pre>
</div>


<h2> See Also </h2>
<h2> See Also </h2>
* [[Units | Units ]]
* [[Units | Units ]]
* [[TclUnit | TclUnit]]
* [[TclUnit | TclUnit]]
{{#seo:|title=RunUnit in Clomosy - Clomosy Docs}}
{{#seo:|description=Learn how to use the Clomosy.Run Unit method to dynamically load and execute specific units in your application, enabling seamles navigation.}}

Latest revision as of 12:00, 20 February 2025

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.

Example 1

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;
}

See Also