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:
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).