While the instruction executer can be handy for quickly testing short pieces of code, it is of course not suited to create real applications. So, let's see now how the usual cycle of coding-compiling-executing-debugging works in Obix.
To keep things simple, we stay with our "Hello world!" example. But this time we will create the source code file that contains the instruction, call the compiler and then execute the code.
As we simply want to execute one instruction, the easiest way to do this is by creating a service with one command that contains the instruction.
Obix source code is stored as plain text in files. Each file contains one root software element (RSE), which is a type, a factory or a service. The file name must be the same as the RSE's prefixed identifier, and the file name extension must be osc. Hence, type employee would be saved in file ty_employee.osc, a factory implementing this type could be saved in file fa_employee.osc, and so on. For more information about source code files please refer to the section called “Source code files” in the programming manual.
Source code can be created with any text file editor. By default, Obix calls Emacs on Linux and Unix systems, and Notepad on Windows systems. At the end of this chapter is a note about how to change these settings so you can use your preferred editor.
To create a new source code object, select Source code / Create new ... from the main menu. After the text editor opens, enter the following source code:
service tutorial_examples
command display_hello
script
se_console.co_message ( "Hello world!" )
end script
end command
end service![]() | Note |
|---|---|
Some elements are always optional in Obix source code:
Hence, the above script could also be written more concisely like this: service tutorial_examples
command display_hello
script
console.message("Hello world!")
end
end
end |
Save the text in file se_tutorial_examples.osc into subdirectory programming/source_code/li_explore of Obix's root directory (e.g. /usr/local/obix/programming/source_code/li_explore/se_tutorial_examples.osc on Linux, and c:\program files\obix\programming\source_code\li_explore\se_tutorial_examples.osc on Windows)
Now compile the source code by selecting Compiler / Compile from the menu. If no error is detected then the system console displays:

In case of a coding error, a popup window like the following appears:

and the list of errors detected by the compiler is displayed on the system console.
For example, the following error message is displayed if we forget to close the string with ":

![]() | Note |
|---|---|
The |
The last step is to tell Obix to execute our service command when we launch the application. This is done by modifying another service command that exists already and that was created when Obix was installed on your system: command start of service explore.
Select Source code / Open ... from the menu. Then open file li_explore/se_explore.osc. Modify command start by adding the instruction se_tutorial_examples.co_start (or tutorial_examples.start if you prefer). The code should look like this:
service explore
command start
script
se_tutorial_examples.co_display_hello
end script
end command
end serviceSave the file.
We have to compile again, because source code has been changed. Select Compiler / Compile all and run from the menu. The run command implicitly calls se_explore.co_start.
The system console displays the result:

![]() | Note |
|---|---|
You can change the editor used for creating source code by modifying file Instead of creating and opening |
![]() | Note |
|---|---|
If your editor has a configurable text highlighting feature (different colors for keywords, literals, comments and other text), then you may want to copy a list of Obix's keywords to the system clipboard and then import them into your editor. You can do this by selecting |
![]() | Note |
|---|---|
There is currently no built-in support for automatic deployment. Obix simply creates Java |
Now we know how to create, compile and execute programs.
if you_are_tired_now then switch_off_your_computer relax else lets_do_more_useful_stuff_and_discover_new_exiting_ways_of_programming end if