From Clomosy Docs
(Created page with "The <b>with & do</b> statement in Clomosy is used to simplify object member access by allowing multiple property or method assignments to be made within a single context block.<br> This structure is particularly useful when working with complex objects, as it eliminates the need to repeatedly specify the object name.<br> <div class="table-responsive"> {| class="wikitable" style="border: 2px solid #c3d7e0" ! style="background-color: #c3d7e0"| Statement !!style="backgrou...") |
|
(No difference)
| |
Latest revision as of 12:41, 3 November 2025
The with & do statement in Clomosy is used to simplify object member access by allowing multiple property or method assignments to be made within a single context block.
This structure is particularly useful when working with complex objects, as it eliminates the need to repeatedly specify the object name.
| Statement | Description |
|---|---|
| with ... do | Creates a scoped block that allows direct access to the specified object’s members without repeating its reference name. |
var
MyForm : TclForm;
ProPanelTop: TCLProPanel;
TitleLabel: TCLProLabel;
{
MyForm = TclForm.Create(Self);
ProPanelTop = MyForm.AddNewProPanel(MyForm, 'ProPanelTop');
with ProPanelTop do
{
Align = alMostTop;
Height = 80;
clProSettings.BorderColor = clAlphaColor.clHexToColor('#890410');
clProSettings.RoundHeight = 10;
clProSettings.RoundWidth = 10;
clProSettings.BorderWidth = 2;
clProSettings.IsFill = True;
clProSettings.IsRound = True;
SetclProSettings(clProSettings);
TitleLabel = MyForm.AddNewProLabel(ProPanelTop, 'TitleLabel', 'Welcome to Clomosy!');
with TitleLabel do
{
Align = alCenter;
Width = 200;
clProSettings.FontSize = 16;
clProSettings.TextSettings.Font.Style = [fsBold];
SetclProSettings(clProSettings);
}
}
MyForm.Run;
}
Note: Avoid using multiple nested with & do blocks whenever possible, as they can reduce readability and complicate debugging.