Introduction.

“Meta-operations are a group of action diagram components that cause processing to be generated, dependent on the triples specified in the model”

Daniel Leigh (Obsydian UG Page 307)

The Obsydian action diagram editor allows you to enter instructions which alter the way function code is generated. This can be to generate many lines of code from a few instructions, or prevent certain code from being generated under specified conditions.

These instructions are separated from normal action diagram instructions by having a '+' as their first character and are called 'meta instructions'.

They are several groups of instructions, each of which will be examined in detail during this course.

Part 1 (this part) will look at simplest set, with a few examples of what you can do with meta code.

Subsequent parts will deal with the more complex instructions and how they are used.

A simple example.

Suppose you want to set all the fields in the Details region of panel to empty. That is, set each character type field to blanks and each numeric type field to zero.

Writing the code to do this using normal action diagram instructions is easy, but when you have thirty or more fields on the panel, it becomes tedious with at least thirty lines of code.

This can be reduced to just 2 lines using simple meta instructions:

This expands to the following C++ code:

// Set Details.Alpha key to empty
v->Details0.Alpha_key0.SetEmpty();
// Set Details.Alpha description to empty
v->Details0.Alpha_description1.SetEmpty();
// Set Details.Bravo key to empty
v->Details0.Bravo_key2.SetEmpty();
// Set Details.Bravo description to empty
v->Details0.Bravo_description3.SetEmpty();
// Set Details.Charlie key to empty
v->Details0.Charlie_key4.SetEmpty();
// Set Details.Charlie description to empty
v->Details0.Charlie_description5.SetEmpty();

In addition to saving you time and effort keying in the instructions, the code reacts to changes you make to the number of fields.
If I add a new field to the panel, the meta instructions will automatically generate the required code for it the next time I generate the function.

What does the code do?

Lets look at each line in turn:

+For each field Details

This tells the meta generator to iterate around each field in the Details variable. Each field in turn is set to the current meta source object. So the first field would be Details<Alpha key>, the second Details<Alpha description>, and so on.

This is one of several meta 'loops' available to you. The others will be examined later.

Inside this 'loop', the next line of code is:

++Set empty

This line tells the meta generator to create a line of code to set the current field to an empty value. To set a field to empty in an action diagram, you need to know three things; the field, the variable it is in and what empty means for the particular field.

The first two of these are derived from the current meta source code object which is set by the previous meta 'loop' instruction. The third thing is worked out by either the generator from the field type; blanks for a character field, zeros for a numeric field, etc... or in the Windows environment runtime.

Because the meta loop iterates six times, six lines of actual code are generated.

The significant things to remember here are:

  1. The meta code in this example only needs to know about the Details variable. The code makes no reference to any of the fields in Details. This allows you to program function in the abstract without knowing what the eventual fields might be.
  2. Only the instruction with the ++ caused code to be generated. The line with the + was used to control the meta generator.
  3. To generate real code, the meta generator needs to have a current source object. The +For each field loop is one way of setting this.

Go to: Top : Next page