From Clomosy Docs

No edit summary
No edit summary
Line 15: Line 15:


The following code must be written to call this procedure in the Main Code.<br>
The following code must be written to call this procedure in the Main Code.<br>
Clomosy.ExecProjectProcedure('Procedurename',Nil,<nowiki>''</nowiki>);
 
</div>
<div class="alert alert-light" role="alert" data-bs-theme="light">
Clomosy.ExecProjectProcedure('Procedurename',Nil,<nowiki>''</nowiki>);
</div>


'''Example:'''<br>
'''Example:'''<br>
Line 21: Line 25:


''Code defined in the procedure;''<br>
''Code defined in the procedure;''<br>
'''var'''
 
MyForm:TFrmClomosyBasisForm;
'''TRObject Syntax'''<br>
lblCaption : TclProLabel;<br>
<pre>
'''begin'''
var
  MyForm:TFrmClomosyBasisForm;
  lblCaption : TclProLabel;
 
{
  MyForm = TFrmClomosyBasisForm.Create(Self);
  MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);
 
  lblCaption = MyForm.AddNewProLabel(MyForm,'lblCaption','');
  clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30,
  "TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center",
  "TextHorizontalAlign":"left","TextBold":"yes"}');
  MyForm.Run;
}
</pre>
 
'''Base Syntax'''<br>
<pre>
var
  MyForm:TFrmClomosyBasisForm;
  lblCaption : TclProLabel;
 
begin
   MyForm := TFrmClomosyBasisForm.Create(Self);
   MyForm := TFrmClomosyBasisForm.Create(Self);
   MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);<br>
   MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);
   lblCaption := MyForm.AddNewProLabel(MyForm,'lblCaption',<nowiki>''</nowiki>);
 
   lblCaption := MyForm.AddNewProLabel(MyForm,'lblCaption','');
   clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30,
   clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30,
   "TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center",  
   "TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center",  
   "TextHorizontalAlign":"left","TextBold":"yes"}');
   "TextHorizontalAlign":"left","TextBold":"yes"}');
   MyForm.Run;<br>
   MyForm.Run;
'''end;'''
end;
</pre>


''Code defined in the Main Code;''<br>
''Code defined in the Main Code;''<br>
'''var'''
 
'''TRObject Syntax'''<br>
<pre>
var
   MyForm:TFrmClomosyBasisForm;
   MyForm:TFrmClomosyBasisForm;
   btnShow : TclButton;<br>
   btnShow : TclButton;
procedure switchScreen
void switchScreen
begin
{
  '''Clomosy.ExecProjectProcedure('LoginScreen',Nil,<nowiki>''</nowiki>);'''
  Clomosy.ExecProjectProcedure('LoginScreen',Nil,'');
end;<br>
}
'''begin'''
 
{
  MyForm = TFrmClomosyBasisForm.Create(Self);
  btnShow= MyForm.AddNewButton(MyForm,'btnShow','Go!');
  btnShow.TextSettings.Font.Size=50;
  btnShow.Align = alCenter;
  btnShow.Height = 50;
  btnShow.Width = 100;
  MyForm.AddNewEvent(btnShow,tbeOnClick,'switchScreen');
  MyForm.Run;
}
</pre>
 
'''Base Syntax'''<br>
<pre>
var
  MyForm:TFrmClomosyBasisForm;
  btnShow : TclButton;
procedure switchScreen
begin
  Clomosy.ExecProjectProcedure('LoginScreen',Nil,'');
end;
 
begin
   MyForm := TFrmClomosyBasisForm.Create(Self);
   MyForm := TFrmClomosyBasisForm.Create(Self);
   btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Go!');
   btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Go!');
Line 49: Line 103:
   btnShow.Height := 50;
   btnShow.Height := 50;
   btnShow.Width := 100;
   btnShow.Width := 100;
   MyForm.AddNewEvent(btnShow,tbeOnClick,'switchScreen');<br>
   MyForm.AddNewEvent(btnShow,tbeOnClick,'switchScreen');
   MyForm.Run;<br>
   MyForm.Run;
'''end;'''
end;
</pre>


'''Output:'''<br>
'''Output:'''<br>
[[File:ExampleProcedure.png|650px|frameless]]
[[File:ExampleProcedure.png|650px|frameless]]

Revision as of 12:30, 25 September 2024

They are used to practically run these operations, which are the subprogram, that is, the procedure, where the operations that need to be run repeatedly are defined and by calling this definition. Of course, procedures just run the process, they don't return a value.

We can define and call procedures in Main Code on Clomosy. Apart from this, it is also called by entering the Management> Codes section. Now let's explain how to do this through an example.

You cannot create a procedure without making the following definitions on this page;

Forms: PROJECT.SCRIPT
User/Normal: Procedure
Events: New Code

Then you should write the name you will give the procedure in the "Param_Name" field. In this way, you can start the coding and complete your process by pressing the save button after the coding is finished.

The following code must be written to call this procedure in the Main Code.

Example:
In the example, let's put a button on our home page and when it is clicked, the procedure we defined will go. First, let's create a procedure.

Code defined in the procedure;

TRObject Syntax

var
  MyForm:TFrmClomosyBasisForm;
  lblCaption : TclProLabel;

{
  MyForm = TFrmClomosyBasisForm.Create(Self);
  MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);
  
  lblCaption = MyForm.AddNewProLabel(MyForm,'lblCaption','');
  clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30,
  "TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center", 
  "TextHorizontalAlign":"left","TextBold":"yes"}');
  MyForm.Run;
}

Base Syntax

var
  MyForm:TFrmClomosyBasisForm;
  lblCaption : TclProLabel;

begin
  MyForm := TFrmClomosyBasisForm.Create(Self);
  MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);
  
  lblCaption := MyForm.AddNewProLabel(MyForm,'lblCaption','');
  clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30,
  "TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center", 
  "TextHorizontalAlign":"left","TextBold":"yes"}');
  MyForm.Run;
end;

Code defined in the Main Code;

TRObject Syntax

var
  MyForm:TFrmClomosyBasisForm;
  btnShow : TclButton;
void switchScreen
{
  Clomosy.ExecProjectProcedure('LoginScreen',Nil,'');
}

{
  MyForm = TFrmClomosyBasisForm.Create(Self);
  btnShow= MyForm.AddNewButton(MyForm,'btnShow','Go!');
  btnShow.TextSettings.Font.Size=50;
  btnShow.Align = alCenter;
  btnShow.Height = 50;
  btnShow.Width = 100;
  MyForm.AddNewEvent(btnShow,tbeOnClick,'switchScreen');
  MyForm.Run;
}

Base Syntax

var
  MyForm:TFrmClomosyBasisForm;
  btnShow : TclButton;
procedure switchScreen
begin
  Clomosy.ExecProjectProcedure('LoginScreen',Nil,'');
end;

begin
  MyForm := TFrmClomosyBasisForm.Create(Self);
  btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Go!');
  btnShow.TextSettings.Font.Size:=50;
  btnShow.Align := alCenter;
  btnShow.Height := 50;
  btnShow.Width := 100;
  MyForm.AddNewEvent(btnShow,tbeOnClick,'switchScreen');
  MyForm.Run;
end;

Output:
ExampleProcedure.png