Chapter 2. First example: "Hello world!"

Let's start with something very easy: the famous "Hello world!" program that simply displays the message "Hello world!". The easiest way to do this is by using the Instruction executer, a useful tool that enables us to write instructions in a text area and then execute them immediately.

After downloading and setting up Obix, start Obix by launching the start batch file in Obix's main directory (e.g. C:\Program Files\obix\start.bat on a Windows system, and /usr/local/obix/start.sh on a Linux system). Then launch the instruction executer by selecting Utilities / Instruction executer ... from the main menu. The following window appears:

Figure 2.1. Instruction executer

Instruction executer

To display a message on the system console we use the command message of service console. This command takes the string to display as input argument.

Enter the following instruction in the text input area:

console.message ( "Hello world!" )

The screen should look like this:

Click on the Execute button.

The message "Hello world!" appears on the system console:

That's all. You just wrote your first 'program' in Obix!

Source code in the instruction executer is not limited to one instruction. We can write a complete script composed of any valid Obix instructions, including program flow instructions like if-then-elses, loops, and so on.

For example, enter the following script:

repeat 3 times
   console.message ( "Hello world!" )
end repeat

Executing this script displays (as you might guess) "Hello world!" 3 times on the system console:

[Note]Note
For more information about instructions in Obix, please refer to Chapter 8, Script instructions in the programming manual