Example Hello world programs


The HBasic IDE can handle different types of sourcecode that may be compiled by one of three compilers. This has some kind of influence on the syntax that you may use in your sourcecode. The sourcecode may be separated by the language (HBasic, C# or HBasic for NET compiler) and the type of library you use. This document should give you an overview by listing some examples of a simple hello world program in different languages and use of different libraries.

Contents



HBasic code with HBasic stdgui library


In this example we use the normal HBasic stdgui library package and start the program execution with the HBasic interpreter or compiler.


Sub button1_clicked()
Print "Hello world"
End Sub

Example hello_world.bas:  Example of a normal HBasic method.



HBasic code with HBasic NET library


In this example we use the normal HBasic stdgui library package and start the program execution with the HBasic interpreter or compiler. Include NET library mscorlib.dll with package manager before executing this program.


Sub button1_clicked()
System.Console.WriteLine( "Hello world" )
End Sub

Example net_hello.bas:  Example of a normal HBasic method.



HBasic code with Qt-C support library


In this example we use the Qt-C support to output a string on the screen. Include NET support in project options before executing this program.


Sub button1_clicked()
Dim s As QString

s = "Hello world"
Print s
End Sub

Example qtc_hello.bas:  Example that uses Qt-C library class QString.



Code for NET compiler

HBasic code with NET compiler


Class mainclass
Static Sub Main
    System.WriteLine( "Hello world" )
End Sub
End Class


Example hello_world.bas:  Example of a normal HBasic method.



C# code code with DotGNU compiler


(result of compilation may be used as library with HBasic)


Using system

Class example
{
void Main()
{
    Console.WriteLine( "Hello world" )
}
}

Example hello_world.bas:  Example of a normal HBasic method.



Hello world in IL Assembler code

IL assembler code may be supported in the future