C# support in HBasic
Contents
Overview
C# is an interesting new language for developers. Since it should also be
possible within HBasic in the future to support code for .net execution environments
implementing support for the C# language should be one step in this direction.
In this first version HBasic can be used to create and edit C# files within
a HBasic project, start the C# compiler to compile the programs and execute
the generated code in the linux environment.
You have to install the GNU dotnet environment before you can use this features.
Install C# support
To use C# you need to download and install the following programs and libraries
from www.dotgnu.org:
pnetlib which creates the library needed with the C# compiler
pnet which creates the main compiler cscc and other tools
You will also need the treecc program to compile the other programs.
Download the newest version of this sources, compile and install them on
your computer.
Copy the file mscorlib.dll (you can normally find it in pnet.x.x/samples)
to the directory /usr/local/hbasic/compiler because the current HBasic version
will search for it only in this directory.
Load C# file
C# sourcecode can be saved like HBasic sourcefiles with the Save functions
of HBasic. Instead of the extension *.bas HBasic will use the *.cs extension
for this files as default if you don'r input a filename with extension.
To load this files into HBasic click on the Open menu entry from the
File menubar or click on the Open toolbutton in the toolbar.
A fileselect dialog will pop up which shows all *.bas files as default.
Select C# source as a new file type within the fileselect dialog and you can
now see and select all *.cs files. Click on one of this filenames and the
OK button to load a C# project into the HBasic IDE.
Create C# project
In the current version of HBasic you cannot mix BASIC sourcecode with C#
files within the same project. Since HBasic starts with a BASIC source project
you have to create a new empty C# project to edit C# files.
To create a new project select New from the File menu or click
on the New toolbar button. A dialog pops up where you can select the
structure that you want to create. Select the Project icon and click
on the OK button.
HBasic will now ask you if you really want to delete the old project files.
After you clicked on the OK button you will get a new dialog where you can
select the type of source files that should be in the new project.
Click on the C# source radiobutton and the OK button to create a new
Project with C# sourcecode.
HBasic will now create a new project with a sourcecode structure that is
marked as C# sourcecode.
Start C# execution
If you have created a new C# sourcecode with the HBasic editor or loaded
a C# file from your harddisk you are now ready to start the C# compiler.
You can start program compilation and execution with a mouseclick on the
Run interpreter toolbutton or click on the Interpreter menu
entry in the Run menubar to start compiling the current C# program.
Since HBasic knows that the current project is a C# sourcecode it start the
C# compiler if this is installed. After successfull compilation the generated
program will be executed and the program output will be displayed within
a special window.