From Clomosy Docs

No edit summary
No edit summary
Line 67: Line 67:
</div>
</div>


<h2> TRObject Hello World Example </h2>


<h2> Variable Declaration</h2>
Following is a simple trobject code that would print the words "Hello, World!"


In the Clomosy platform, variable declaration is an important step for storing and processing data during the execution of a program. Variables are defined to hold values of a specific data type and can be used in different parts of the program. When declaring a variable, the var keyword is used first. Under this keyword, multiple variables can be defined.<br>
<b>TRObject Syntax </b>
<pre>
{
  ShowMessage('Hello World!');
}
</pre>


Under the <b>var</b> keyword, the name of the variable to be declared is specified first, followed by the data type to be used (for example, integer, floating-point, or text). This allows values to be dynamically assigned during the program flow, enabling various operations to be performed on these values. Proper variable declarations enhance code readability and facilitate program maintenance.
<b>Base Syntax </b>
<pre>
begin
  ShowMessage('Hello World!');
end;
</pre>
 
This will produce following result<br>
 
<div class="alert alert-light" role="alert" data-bs-theme="light">
Hello World!
</div>
 
Let us look various parts of the above program<br>
 
<div class="alert alert-primary" role="alert" data-bs-theme="light">
* The first line of the program is enclosed in { and } in TRObject syntax, and in begin and end statements in Base syntax; these form the main program block. In Clomosy, every block is enclosed by a start ({ or begin) statement and an end (} or end) statement.
* The start ({ or begin) statement of the main program block is where the program execution begins.
* The statement ShowMessage('Hello, World!'); uses the ShowMessage function available in Clomosy to display the message "Hello, World!" on the screen.
* The last statement (} or end) ends your program.
</div>
 
<b> Execute Clomosy Program </b>
 
<div class="alert alert-success" role="alert" data-bs-theme="light">
* Open the Clomosy developer editor (cms.clomosy.com) and add the code mentioned above.
* Save the program by pressing Ctrl+S or clicking the 'Save' button.
* Include the Clomosy Learn application by [[Clomosy_Installation | downloading]] and [[Users | signing in]].
* After including the project, click on the project name.
* You will see "Hello World" displayed on the screen, and the program will wait until you press any key.
</div>

Revision as of 11:51, 2 October 2024

The Clomosy platform offers two different syntax structures to provide flexibility and functionality in programming: TRObject and Base. Both structures serve different use cases and bring distinct approaches to the programming process.

Below are the headings for different usage structures of syntax used in the Clomosy platform. How each syntax is utilized will be detailed under the respective topics.

  • Loops
  • Conditions
  • Operators
  • Error Handling
  • Procedure Usage

Every Clomosy program has an execution section in a specific order. The following format shows the basic syntax of a Clomosy program:


TRObject Syntax

const //global constant declaration block
var //global variable declaration block

function //function declarations, if any
  //local variables
{
...
}

void //procedure declarations, if any
  //local variables
{
...
}

{ //main program block starts
...
} //the end of main program block 

Base Syntax

const //global constant declaration block
var //global variable declaration block

function //function declarations, if any
  //local variables
begin
...
end;

procedure //procedure declarations, if any
  //local variables
begin
...
end;

begin //main program block starts
...
end; //the end of main program block 

TRObject Hello World Example

Following is a simple trobject code that would print the words "Hello, World!"

TRObject Syntax

{
  ShowMessage('Hello World!');
}

Base Syntax

begin
  ShowMessage('Hello World!');
end;

This will produce following result

Let us look various parts of the above program

Execute Clomosy Program