Meta-operations are a group of action diagram components that cause processing to be generated, dependent on the triples specified in the modelDaniel 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.
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 |
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.
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: