Creating NET code with HBasic


The first version of HBasic was capable of creating and running it's own form of runtime code. Since it is helpfull for the developer that he may include as many working external libraries as possible HBasic can access class definitions within a NET library. Currently this NET libraries will normally be created with a C# compiler. In this form you can only import C# programs into your HBasic project.

With the NET compiler it will also be possible to create NET code from HBasic code. This will be included into the existing compiler which has to create another form of destination code. The code generated by the NET compiler can then be integrated into other C# or HBasic projects which use the NET execution environment.

This compiler is in a very early alpha state but will be extended in the following versions of HBasic step by step.

The next program shows an example how a program for the NET compiler might look like. Since there is currently no integration for forms and grafical elements in the NET library we show an example program that outputs a text line to the console.


Class
Sub Main
Print "Hello NET world"
End Sub
End Class


Example hello_world.bas:  Example of a HBasic program for the NET compiler.

Compile this program with "Run/ Net Compiler". A file /usr/local/hbasic/hbasic.s with IL code and a net executable will be generated which could also be started with "ilrun <progname>".