Gekko programs

<< Click to Display Table of Contents >>

Navigation:  Gekko User Guide > Data Management User Guide >

Gekko programs

Previous pageReturn to chapter overviewNext page

Show/Hide Hidden Text

When using Gekko in daily work, you will usually use Gekko program files, if you have a program that takes up more than a few statements, and the statement sequence will be run several times. A Gekko program file is an alternative to typing each statement interactively in the Gekko main window. An additional advantage of using Gekko programs i reproducibility and documentation. A Gekko program is characterized by two properties:

 

It contains only Gekko statements.

It is a system file with file extension .gcm.

 

To run a Gekko program file with the name data.gcm, type:

 

run data; //Gekko will add extension .gcm

 

All the statements in the file will then be executed as if they were issued interactively from the statement window.

Below is an example of a Gekko program as it will look in Notepad (read more about editors: +toggle).

 

// ----- file start -----
read hist1115;
ul = ua - q;
prt ul;
// ----- file end -------

 

The above file first loads the historical databank hist1115.gbk. Next, the number of unemployed (ul)  for the current period is calculated and printed.

 

It is advised to include comments in Gekko programs. This increases readability both for the user him/herself, but especially for other users who need to understand the contents of the file. Comments can be included in the file with either:

 

// some text

/* some text */

 

The former (// ...) only out-comments the rest of the current line, wheras the latter (/* ... */) can span several lines and is therefore practical for multi-line commentaries, or for out-commenting larger blocks of code (read about other ways of skipping code: +toggle).

 

Besides gcm program files, Gekko also recognizes files named gekko.ini (henceforeward called the 'ini file'). The file usually contains a number of custom options that the user wants Gekko to set at startup. The options can, for example, set the folder structure for which Gekko should look for model files, bank files, and Gekko programs, along with other more general settings like setting the global time period, frequency, etc. The ini file is run automatically, if Gekko is started from a folder in which such a file exists (otherwise, the INI statement can execute the ini file on demand, and the RESTART statement resets Gekko and subsequenctly runs the ini file). An example of the contents of an ini file could be:

 

option folder bank = C:\Datop\bank\;
option folder command = C:\Datop\;
run period.gcm;
read hist1115;
time 2010 2020;

 

The first two lines define the folders in which Gekko searches for data banks (option folder bank) or Gekko program files (option folder command). When bank and Gekko programs paths are defined as above, in subsequent statements it is not necessary to use full path indication if you open up a data bank or run a Gekko program. The third statement loads date variables from an external period.gcm file. Finally, a databank is read, and the global time is set.

 

It is a good idea to start your Gekko program with the following:

 

restart;

 

which closes all data banks, clears everything (including options, etc.), and re-runs gekko.ini. A RESTART is essentially equivalent to closing the Gekko main window, and starting Gekko up again. Related to RESTART is the RESET statement, which also closes all data banks but omits to run any ini file.

 

reset;

 

With RESET, a gekko.ini file is not searched for and run. There is the following equivalence: restart = reset; ini;. Since both RESTART and INI do not abort with an error if no ini file is found, if you need to be absolutely certain that a gekko.ini file is found and run (and no-one accidentally deleted the file), instead of restart; at the top of your Gekko program, you can use reset; run gekko.ini;. In that way, if the ini file is not found, Gekko will stop with an error.

 

If you need to clear the output window, you can use CLS (clear screen):

 

cls;

 

Neither RESET nor RESTART clears the output window, so cls; RESTART; is often seen in combination.

 

Read more about Gekko programs in the sub-sections.