Building A Program Class


The simplest programs consist of a single Gilda, C, or C++ file. Compiling the file builds an executable program. Larger programs have a primary class file. When compiled the class file brings in any procedures and additional classes into the build to produce an executable program.

The primary class cannot be a generic class. The primary class body usually declares a gilda file designated with the Root keyword as the starting point for the program. If it doesn't another class imported in the build will need to designate a Root method. While importing additional classes, if one of them also declares a Root method it will be not be used as the starting point.

Program arguments are passed into the Root procedure using a standard signature. Here is an example Print Argument program that prints out its arguments.

When you build a program the compiler first imports all the classes used in the build. Types and class globals are declared. They also map out where all the procedure files are located. Next all the procedure files used by the program are compiled and linked to produce an executable program. Note that many more procedures may be mapped, but only the required procedures are compiled.

When one procedure calls another then the called procedure is added to the build. Data files are automatically added to the build when they are used by a procedure. There may still be additional procedures that are needed to build a complete program. Calls to procedures in foreign languages (usually C/C++) are not automatically included. You can designate them using a dependency.

In the class body a dependency line can be coded immediately following a procedure member declaration. The dependency line lists additonal procedures to include in the build whenever the member is built. There can be more than one dependency line. Dependency lines start with a right arrow ("=>").


Generating Primary Gilda Source Code


If a version of the class or help files exist they will not be generated unless you allow it. The -All, -Class, and -Help switches are overrides to rewrite these files.

The generated primary class imports the Program.Argument class in the Basis library. It has procedures that process program arguments. This example RC Filter program shows how a simple program can be built.