From a tool-developers point of view one of the weaker areas in the Presentation Server has always been the lack of a “reflection API”, i.e. a way to discover what properties, methods and events an object actually supports at runtime. This in turn has led to creating manual lists and records of object attributes, bringing with it with the inherent difficulty of keeping this information up-to-date as new features are added.
Primarily designed with the new PS-based Form Designer in mind, this shortcoming has been addressed in version 10 with the addition of the following new methods to the SYSTEM object:
Each of these methods takes a single argument which is the type of object to query:
buttonProperties = exec_Method( "SYSTEM", "REFLECT_PROPERTIES", "PUSHBUTTON" ) buttonMethods = exec_Method( "SYSTEM", "REFLECT_METHODS", "PUSHBUTTON") buttonEvents = exec_Method( "SYSTEM", "REFLECT_EVENTS", "PUSHBUTTON" )
Each method in turn returns a dynamic array of information describing the requested attribute type:
- REFLECT_PROPERTIES returns the name of each property and the type of the data it represents. It also identifies the context that the property is valid for (Devtime/Runtime/Get/Set).
- REFLECT_METHODS returns the name of each method, along with a list of arguments the method accepts and the type of data each argument should contain.
- REFLECT_EVENTS returns the name of each event the object type can raise along with the names and data types of arguments passed to an event handler.
Note that when these methods return the type of data for a property or argument there are some cases where only a broad hint is given – Basic+ is an untyped language so it is not really feasible to accurately describe some types using a simple set of flags – e.g. in the case where an argument is a complex dynamic array containing a variety of other core data types such a strings and numbers.
Whilst aimed mainly at developers who write development tools for OpenInsight, this API may still be of interest for those of you who like to write your own diagnostic and debugging tools – when a new property, method or event is added to the Presentation Server it is clearly exposed thereby reducing the likelihood of it remaining hidden and undocumented.
[Edit: 24 Apr 13 – Call_Method renamed to Exec_Method]
(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).