Category:Elena: Difference between revisions
Content added Content deleted
Line 16: | Line 16: | ||
To create a simple console program we have to declare the program symbol in the project root namespace: |
To create a simple console program we have to declare the program symbol in the project root namespace: |
||
public program |
public program |
||
[ |
[ |
||
] |
] |
||
Everything in ELENA is an object. To interact with it we have to send a message. The simplest (generic, i.e. without an explicit signature) message consists of an action and a parameter list. |
Everything in ELENA is an object. To interact with it we have to send a message. The simplest (generic, i.e. without an explicit signature) message consists of an action and a parameter list. |
||
Line 24: | Line 24: | ||
The statement should be terminated by a dot (ELENA is inspired by Smalltalk and uses its syntax notations). |
The statement should be terminated by a dot (ELENA is inspired by Smalltalk and uses its syntax notations). |
||
public program |
public program |
||
[ |
[ |
||
console writeLine("Hello!") |
console writeLine("Hello!") |
||
] |
] |
||
In our example the action is writeLine and the parameter list consists of a single literal constant. The message target is console object (implementing input / output operations with a program console). |
In our example the action is writeLine and the parameter list consists of a single literal constant. The message target is console object (implementing input / output operations with a program console). |
||
Line 33: | Line 33: | ||
Several message operations can be done in a single statement separated by a semicolon: |
Several message operations can be done in a single statement separated by a semicolon: |
||
public program |
public program |
||
[ |
[ |
||
console writeLine("Hello!"); writeLine("How are you?"). |
console writeLine("Hello!"); writeLine("How are you?"). |
||
] |
] |
||
The result will be: |
The result will be: |
||
Line 45: | Line 45: | ||
We may read a user input by sending readLine message without parameters: |
We may read a user input by sending readLine message without parameters: |
||
public program |
public program |
||
[ |
[ |
||
console write("What is your name:"); writeLine("Hello " + console readLine). |
console write("What is your name:"); writeLine("Hello " + console readLine). |
||
] |
] |
||
The result will be: |
The result will be: |