Workbook for SLD Offline Users - Writing Code: The Constants System

To use the constants system in its simplest form, you need to:

Creating a Constants File

Constants files are easy to create. They look a little like .TEMPLATE files, except they define initial values rather than defining data structures.

Constants files always have the file extension .CONSTANT. Sometimes they have the same file name as the corresponding .TEMPLATE, but this not required.

As a first example, look at the constants file that the Event Display uses to define what kinds of objects you can DSP ADD.

Get both of these files into your editor so you can compare them.

In the template file, notice that each DSPTYPS bank has a GNAME, a GDESC and some other elements including a repeat block called TYPE. Don't worry too much about the details. Just understand the overall structure. There may be any number (up to a MAXID of 32) different DSPTYPS banks. Each DSPTYPS bank can contain some variable number of TYPE blocks.

Now look at the constants file: PRODDISPLAY:DSPTYPS.CONSTANTS. You should see constans for 3 DSPTYPS banks.

If you just study the .CONSTANTS file and the corresponding .TEMPLATE file, the system should become clear to you.

Reading a Constants File

In the detailed section, Writing Code: Using Jazelle from Prepmort, you saw that you can add a Jazelle bank by calling the routine JZBADD.

For example, your Prepmort file could contain the line:

This would create a DSPTYPS bank based on the DSPTYPS.TEMPLATE. But this would not read the constants file. The only initial values you would get would be those that were set in the template file.

To create banks with initial values based on a constants file, you instead use the routine JZKGET.

For example, your Prepmort file could contain the line:

This would create a set of DSPTYPS banks based on the data in DSPTYPS.CONSTANT.

The option 'RELOAD' insures that if there already was such a bank, it will be replaced. If you specify ' ' instead of 'RELOAD', any bank that already existed will be left untouched.

This is almost all you will need to learn about the constants system unless you get into very advanced software. In that case, consult section 12 of the Jazelle manual. One note on that manual, it says that run-dependent constants are not yet implemented. They are indeed now implemented.

A Note on File Names

It is not necessary for a constants file to have the same file name as the corresponding template file.

It is the name inside the constants file, in the BANK statements, that needs to match the template file name.

The thing that cares about the constants file name is the JZKGET routine.

For example, things would work out fine if we:

In fact, a single constants file can contain constants information to fill many different templates. As an example, look at the file PRODDISPLAY:DSTUDSP.CONSTANT. This file defines everything the Event Display system needs to know to about displaying Mini-DST information.

The file contains the following kinds of banks:

When you issue the event display command that adds the Mini-DST display system,
the first thing the event display does is run the statement

Back to Writing Code

Joseph Perl
28 February 1995