Download Qlarity Foundry User`s Manual
Transcript
Advanced Design Create a New Object Template The illustration above shows a portion of an example of the “boilerplate” code provided by QSI as an optional starting point when creating a new object template. The boilerplate code included in a new template depends on the type of object being created (i.e., non-drawable, area object, or container). The purpose of the boilerplate code is to provide a set of properties and methods found in a typical object of the selected type. It also provides fully functional tool methods. The source code is well documented and serves as an example of a working Qlarity object. Each property is defined as follows: descriptive comment (describe the property) dim statement (create the property) init statement (assign a default value) validation method (provide functionality for property changes) For example, the “enabled” property is common to all objects and appears in the boilerplate code for any type of template. The code that defines the property is as follows: ‘Whether the object is displayed on the terminal dim enabled as boolean init enabled := true func enabled(newval as boolean) enabled := newval Enable (me, enabled) endfunc The comment describes the purpose of the property. The “dim” statement creates a boolean property named “enabled.” The “init” statement assigns a default value of TRUE to the enabled property, which means that if the property is not assigned an initial value in the object instance, the value defaults to TRUE. Finally, the validation function (see section 10.2, “Validation Functions”) describes the behavior of the object when the value of “enabled” is changed. The validation function first does a strict assignment of the new value to the property then calls the Enable() API function to inform the firmware that the enabled status of the object has changed. Calling API functions to implement the effects of a property change is a very common activity in validation methods. An example of another property found in all versions of the boilerplate code is the “parent” property, as follows: ‘Who do we attach to dim parent as objref init parent := default func parent(newval as objref) parent := newval Attach(me, parent) endfunc QSI Qlarity Foundry 155