There is an interesting "shortcut" available to you by using "Compound Object References". In some cases, you'll find that you can combine two, three, or more method calls into a single line of PowerBASIC source code.
The notion here is that you may need to execute a METHOD which returns an object variable, just so you can use that temporary object variable to call another method. In fact, you may even find you need to nest this type of operation several levels deep! While this is certainly workable, you may find yourself with a maze of temporary objects and object variables, all of which need to be destroyed at some point.
For example, assuming you have an object variable named MyDBase, which is an instance of the interface named DataBase. The interface DataBase offers a method named ErrorObject which returns an Errors object. Errors is a second interface, which has a method named Count. Count returns a long integer, to tell the number of errors which have occurred. In order to retrieve Count, you would normally have to write:
LOCAL MyErrors AS Errors
LET MyErrors = MyDBase.ErrorObject
ErrorCount& = MyErrors.Count
MyErrors = NOTHING
However, with Compound Object References, this can be combined into a single line of code:
ErrorCount& = MyDBase.ErrorObject.Count
In particular, note that the temporary object called MyErrors is gone completely, since PowerBASIC automatically handles the lifetime of temporary objects. You can even declare the methods and properties with parameters, if it's appropriate to allow:
ErrorCount& = MyDBase.ErrorObject(item&).Count
See Also