From Clomosy Docs

No edit summary
No edit summary
Line 1: Line 1:
<span style="color:red">Ask Method Supported Only For Windows. You can use [[AskAndCall | AskAndCall]].</span>
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function Clomosy.Ask(var AAskMessage:String): Boolean;
</div>


The "Ask" function is commonly used in Clomosy programming to display a dialog box where you can request user confirmation. You can use this function to ask a question or present options to the user.
The "Ask" function is commonly used in Clomosy programming to display a dialog box where you can request user confirmation. You can use this function to ask a question or present options to the user.<br>


Clomosy.Ask('Do you like Clomosy?');
By using "Clomosy.Ask," you can input a specific question. If the "Yes" button is clicked, the function returns a value of true. Otherwise, it returns false, allowing you to perform the desired operations.<br>


By using "Clomosy.Ask," you can input a specific question. If the "Yes" button is clicked, the function returns a value of true. Otherwise, it returns false, allowing you to perform the desired operations.
<div class="alert alert-danger" role="alert" data-bs-theme="light">
Ask Method Supported Only For Windows. You can use [[AskAndCall | AskAndCall]].
</div>


'''Example:'''<br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
<pre>
{
  if Clomosy.Ask('Do you like Clomosy?')
    ShowMessage('Yes');
  else
    ShowMessage('No');
}
</pre>
<b>Base Syntax</b><br>
<pre>
begin
  if Clomosy.Ask('Do you like Clomosy?') then
    ShowMessage('Yes');
  else
    ShowMessage('No');
end;
</pre>


:'''TRObject Syntax'''
<h2> See Also </h2>
  var
* [[System_Library#Input-Output_Functions | Input Output Functions]]
  MyForm:TCLForm;
  askBtn:TCLButton;
  getEdit :TClEdit;
  void ProcYes;
  {
    ShowMessage('Yes Clicked');
  }
  void ProcNo;
  {
    ShowMessage('No Clicked');
  }
  void askBtnOnClick;
  {
   
    if not(getEdit.Text == <nowiki>''</nowiki>)
    {
      if (Clomosy.Ask(getEdit.Text))
        ProcYes;
      else
        ProcNo;
      }
      else
      ShowMessage('Please enter a question.');
  }
 
  {
  MyForm = TCLForm.Create(Self);
  getEdit = MyForm.AddNewEdit(MyForm, 'getEdit','Enter the question...');
  getEdit.Align=alMostTop;
  getEdit.Margins.Top=20;
  getEdit.Margins.Right=20;
  getEdit.Margins.Left=20;
 
  askBtn= MyForm.AddNewButton(MyForm,'askBtn','Ask Function');
  askBtn.Align=alTop;
  askBtn.Margins.Top=20;
  askBtn.Margins.Right=20;
  askBtn.Margins.Left=20;
 
  MyForm.AddNewEvent(askBtn,tbeOnClick,'askBtnOnClick');
 
  MyForm.Run;
  }
 
:'''Base Syntax'''
var
  MyForm:TCLForm;
  askBtn:TCLButton;
  getEdit :TClEdit;
  procedure ProcYes;
  begin
    ShowMessage('Yes Clicked');
  end;
  procedure ProcNo;
  begin
    ShowMessage('No Clicked');
  end;
  procedure askBtnOnClick;
  begin
 
    if getEdit.Text <> <nowiki>''</nowiki> then
    begin
      if Clomosy.Ask(getEdit.Text) then
        ProcYes;
      else
        ProcNo;
    end else
      ShowMessage('Please enter a question.');
  end;
begin
  MyForm := TCLForm.Create(Self);
  getEdit := MyForm.AddNewEdit(MyForm, 'getEdit','Enter the question...');
  getEdit.Align:=alMostTop;
  getEdit.Margins.Top:=20;
  getEdit.Margins.Right:=20;
  getEdit.Margins.Left:=20;
  askBtn:= MyForm.AddNewButton(MyForm,'askBtn','Ask Function');
  askBtn.Align:=alTop;
  askBtn.Margins.Top:=20;
  askBtn.Margins.Right:=20;
  askBtn.Margins.Left:=20;
  MyForm.AddNewEvent(askBtn,tbeOnClick,'askBtnOnClick');
  MyForm.Run;
end;

Revision as of 14:23, 7 October 2024

The "Ask" function is commonly used in Clomosy programming to display a dialog box where you can request user confirmation. You can use this function to ask a question or present options to the user.

By using "Clomosy.Ask," you can input a specific question. If the "Yes" button is clicked, the function returns a value of true. Otherwise, it returns false, allowing you to perform the desired operations.

Example
TRObject Syntax

{
  if Clomosy.Ask('Do you like Clomosy?')
    ShowMessage('Yes');
  else
    ShowMessage('No');
}

Base Syntax

begin
  if Clomosy.Ask('Do you like Clomosy?') then
    ShowMessage('Yes');
  else
    ShowMessage('No');
end;

See Also