The Meta Instruction Set - Meta Variables.

 A Little Bit of Theory.

The first phase in the generation of an Obsydian function is performed by the meta generator. This finds and expands all the meta instructions, turning them into normal action diagram instructions (where appropriate). This code is then passed to the regular action diagram generator to create the target language source code.

During this first phase, Obsydian allows you to control the meta generator through special meta instructions. These all start with +++ and do not result in any actual code being generated.

The Meta Variable.

A meta variable can be thought of as a storage area which exists only at generation time. You create a meta variable by using the +++Define instruction. This takes any model object as its parameter. Generally, the object you choose as the parameter is just for identification purposes, allowing you to use it again, later in the code. The class libraries often use specially created field objects with names specific to their purpose. It is purely a means of identifying to the meta generator which meta variable you are referring to.

Defining a meta variable does two things:

  1. Makes the meta variable exist. This existence can be tested for in other meta instructions.
  2. Sets the object to which the meta variable 'points'. Initially the meta variable points to the object from which it was defined.

The object to which the meta variable 'points' can be changed using the +++Set value instruction and can be any object in the model. Lets look at an example:

+++Define Field: Function name
+++Set Value
Field Function name, Function: Display Customers

Here the first line create a meta variable known as Field: Function name. This is the identifier we have to use when using the meta variable later in the code. It also set the Field: Function name meta variable to point to the Function name field in our model.

The second line changes which object is being pointed to. In this case, the instruction changes the Field: Function name meta variable to point to the Display Customers function.

Both of these properties of a meta variable can be used to control code generation.

The existence of a meta variable can be tested for in meta conditions, covered in a later part, so you need to be able to destroy a meta-variable. This is done using the +++Undefine instruction.

An additional way to set a meta variable is to use the +++Set Value To Current instruction. This takes a meta variable as its parameter and it sets the object which the meta variable points to. The object used is the CMSO most recently set in the meta code. For an example of defining and setting meta variables, look at the code in the OBASE Relation & view validation function:

There are five meta variables defined at the beginning of the function and these are set to point to objects later in the code. The highlighted line sets the Field: +Current relation meta variable to point to a triple, an entity relation triple in this case since it is inside a +For Each Entity Relation meta loop.

The +++Set Value instruction eight lines down uses a verb to set the meta variable rather than using a specific object. In this case the Field: +External field meta variable is set to the target object of the current FLD Displayed as FLD triple.

Two lines on, the +++Set Value To Current instruction is inside a +For Each Field loop.This sets the Field: +Current field meta variable to each of the attribute fields of each entity relation in turn.

There are also two tests using meta variables in this piece of code. They are covered on the next page.

Go to: Top : Next page