GXC Language Reference
Hello World
For example, following is a very simple GXC program that displays a "hello world" message to the user. Comment lines beginning with //, as well as blank lines, are ignored by the compiler. This program contains all the minimum required elements of a GXC program. To compile and run this program:
- Copy this text into a file named "
hello.gxc
". - Compile the GXC (make sure you have the GXC compiler in your path, or call it explicitly):
gxc hello.gxc
- This will create a file named
hello.gx
. Open Oasis montaj, click on the GX button and choose this GX to run.
HelloWorld.gxc
//====================================================================== // // Lines starting with // are comments, you can have as many as you want // and the compiler will ignore them. Standard C-style comments /*...*/ // are also supported. Blank lines are ignored by the compiler. NAME = "Say hello" VERSION = "v1 Copyright Geosoft Inc. 1999" DESCRIPTION = "Just say Hello" // Every GX begins with these three keywords (NAME, VERSION and DESCRIPTION), // which are assigned to strings that identify and describe the GX. //=========== Resource Section ========================================= // This gx doesn't have a user interface (ie dialog), so it doesn't have // any resources. But if it did, they would be included as shown here //RESOURCE = "HelloWorld.gr" //#include "HelloWorld.grh" //====================================================================== #include <all.gxh> // The GX API (Application Programming Interface) is described in gxh files // in the GxDev/gxh directory. This statement includes the file all.gxh, // which in turn includes all other gxh files. The gxh files provide // prototypes of all functions together with and function documentation for // the GX programmer. //=========================================================================== // GLOBAL VARIABLES //=========================================================================== // This simple example does not require any variables, but if it did, all // variables would be declared here. { // --- start program statements --- DisplayMessage_SYS("Hello","Hello world"); } // --- program end ---
Note: Unlike some other programming languages, the C and GXC languages are case sensitive. This means that the tokens “DisplayMessage_SYS” and “displayMESSAGE_sys” are different to the GXC compiler.