GEOS SDK TechDocs
|
|
4 The Source File and Source Code
|
4.2 The Process Object
As Inclusion Files and Global Variables shows, the first thing in a .goc file is a list of other files and libraries that must be included. These are designated in the standard C protocol, with one exception (described below). All the inclusions and libraries a basic application will need are shown in the sample, and only the following inclusions is required of every GEOS application:
@include <stdapp.goh>
Other inclusions may be required for more complex applications and libraries, and these inclusions will be listed in the topics that require them. Goc accepts both the standard C
#include
for
.h
files and the GEOS
@include
for
.goh
files. The difference between them is that
.h
files may not include Goc constructs (e.g.
@object
) whereas
.goh
files can.
After the inclusions are listed, you should declare any global variables used throughout your application. Be aware that global variables, though accessible by any object, are owned by the application's Process object and by the application's primary thread. Objects running in other threads (such as UI objects) should not access these global variables directly because this can cause synchronization problems between threads.
Whenever possible, you should avoid using too many global variables. Global variables are typically put in a fixed-block resource, and having too many can bog down a low-memory machine.
The Hello World application uses only two global variables. The first,
helloTextColor
, holds the value of the currently-displayed text color and is initialized to the value C_BLUE (dark blue). The second,
winHan
, contains the window handle of the scrollable view into which we draw our text. How these variables are used will be shown later.
Code Display 2-2 Inclusion Files and Global Variables
This is the first portion of the hello3.goc file.
/*********************************************************************** * Copyright (c) GeoWorks 1991, 1993-- All Rights Reserved * * PROJECT: GEOS * MODULE: Hello World (Sample GEOS application) * FILE: hello3.goc (Code file for Hello World Sample Application) * * DESCRIPTION: * This file contains the source code for the Hello World application. * This code will be processed by the goc C preprocessor and then * compiled by a C compiler. After compilation, it will be linked * by the Glue linker to produce a runnable .geo application file. * ***********************************************************************/
/*************************************************************************** * Include files * These files are the standard inclusion files to use the basics of * the GEOS system and libraries. All applications should include * at least the following files. Note that all inclusion files * have the suffix .h or .goh indicating they are header files. ***************************************************************************/
@include <stdapp.goh> /* Standard GEOS inclusion file */
/*********************************************************************** * Global Variables ***********************************************************************/
word helloTextColor = C_BLUE; WindowHandle winHan;
GEOS SDK TechDocs
|
|
4 The Source File and Source Code
|
4.2 The Process Object