Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The main code of a GX is contained in a text file with extension .GXC.  Optional dialog resources are described in one or more files with extension .GRC.  To create a GX, one writes and debugs code contained in GRC and GXC files.  Compiling a GXC file will create a compiled Geosoft GX file that contains both the compiled GXC code and the resources compiled from the GRC.  The final GX can be run from any Oasis montaj platform that supports GX API functions called by the GX (see Oasis montaj Menus).

This part of the documentation describes how to use the GX Developer compilers and provides reference information about the language rules and syntax. GX Program Structure  and the sections that follow, provides a topic-oriented reference guide that explains how to use a number of key components in the system.

You will use GXC, the GX Programming Language, to create GX programs. GXC is a C-like language that includes the majority of C expressions and control statements together with a simplified set of data types. Our objective in the GXC language is to keep the language easy-to-use, so GXC does not include support for pointers, structures or callable functions other than those included in the Geosoft function libraries (the GX API) or in other DLL’s that conform to the GX API requirements. The power of programming with GXC comes from using the GX API, which provides access to the extensive library of methods in the Geosoft engine that is included as part of Oasis montaj.

The GX API provides methods to create, read and write Geosoft data files (grids, databases, maps, etc.), and access to the xtensive library of processing capapbilities upon which Oasis montaj is built. The GX API for GXC is self-documented in the GXC header files, which you will find in the 9.7 8 GXH Headers.

GXC source code is compiled using the GX source code compiler gxc.exe (C:\Program Files\Geosoft\Desktop Applications 9\bin\gxc.exe). As with standard C, your source code is first translated by a C-Pre-processor that modifies the code based on Pre-processor directives. Pre-processor directives can be used to control which code is compiled, define constants, define macro statements to be re-used in your code, and to include other files in the compilation. See Preprocessor Directives for more information.

This chapter describes the basic C language that is implemented in GXC.


Info
iconfalse
titlePage tree

Page Tree
rootGXD98: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:

  1. Copy this text into a file named "hello.gxc".
  2. Compile the GXC (make sure you have the GXC compiler in your path, or call it explicitly):
       gxc hello.gxc
  3. This will create a file named hello.gx .  Open Oasis montaj, click on the GX button and choose this GX to run.


Code Block
languagecpp
titleHelloWorld.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.