From Clomosy Docs
(Created page with "asdasdasd") |
No edit summary |
||
| Line 1: | Line 1: | ||
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.<br> | |||
<blockquote style="background-color:#CBEDD5"> If you don't know the procedure definition, check the [[Clomosy_Language#Procedure_Declarations | Procedure Declarations]] page.</blockquote > | |||
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.<br> | |||
You cannot create a procedure without making the following definitions on this page;<br> | |||
:'''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.<br> | |||
The following code must be written to call this procedure in the Main Code.<br> | |||
Clomosy.ExecProjectProcedure('Procedurename',Nil,<nowiki>''</nowiki>); | |||
'''Example:'''<br> | |||
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.<br> | |||
''Code defined in the procedure;''<br> | |||
'''var''' | |||
MyForm:TFrmClomosyBasisForm; | |||
lblCaption : TclProLabel;<br> | |||
'''begin''' | |||
MyForm := TFrmClomosyBasisForm.Create(Self); | |||
MyForm.SetFormColor('#CBEDD5','#E6E2C3',clGVertical);<br> | |||
lblCaption := MyForm.AddNewProLabel(MyForm,'lblCaption',<nowiki>''</nowiki>); | |||
clComponent.SetupComponent(lblCaption,'{"Caption":"Welcome!","Align" : "Center","Width" :170, "Height":30, | |||
"TextColor":"#4d6e56","TextSize":35,"TextVerticalAlign":"center", | |||
"TextHorizontalAlign":"left","TextBold":"yes"}'); | |||
MyForm.Run;<br> | |||
'''end;''' | |||
''Code defined in the Main Code;''<br> | |||
'''var''' | |||
MyForm:TFrmClomosyBasisForm; | |||
btnShow : TclButton;<br> | |||
procedure switchScreen | |||
begin | |||
'''Clomosy.ExecProjectProcedure('LoginScreen',Nil,<nowiki>''</nowiki>);''' | |||
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');<br> | |||
MyForm.Run;<br> | |||
'''end;''' | |||
'''Output:'''<br> | |||
[[File:ExampleProcedure.png|650px|frameless]] | |||
Revision as of 10:43, 22 February 2023
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.
If you don't know the procedure definition, check the Procedure Declarations page.
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.
Clomosy.ExecProjectProcedure('Procedurename',Nil,'');
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;
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;
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;