Getting a public property dynamically?

Posted by gabspeck on 31-Aug-2011 20:08

Hi,

Is it possible to use to get a public property defined in a class through a dynamic call?

I've tried using DYNAMIC-INVOKE, but it simply fails as if I called a non-existant method.

As a sidenote, while running some simple programs to try and do it I found out the following:

This ".p" causes a GPF:

DYNAMIC-INVOKE("Progress.Lang.Object", /*or any other valid class in your PROPATH */

               "non_existant_method"). /* GPFs*/

While this one does not:

DEFINE VARIABLE some_obj AS Progress.Lang.Object /* or any other valid class, not necessarily the same as the one you DYNAMIC-INVOKE on*/

DYNAMIC-INVOKE("Progress.Lang.Object", /*or any other valid class in your PROPATH */

               "non_existant_method"). /* Shows ABL error message */

Pretty neat, huh? Doesn't happen if you pass a class instance object as the first argument to DYNAMIC-INVOKE.

All Replies

Posted by gabspeck on 31-Aug-2011 20:23

Well, seems this is planned for OE 11. From http://communities.progress.com/pcom/docs/DOC-107039:

Dynamic Properties allow you to set and get ABL class properties dynamically.

Seems I'm stuck with plain ol' getter methods for now.

Posted by jmls on 01-Sep-2011 00:30

there are no dynamic properties yet.

On 1 September 2011 02:08, Gabriel Speckhahn

Posted by Peter Judge on 01-Sep-2011 07:27

gabspeck wrote:

Well, seems this is planned for OE 11. From http://communities.progress.com/pcom/docs/DOC-107039:

Dynamic Properties allow you to set and get ABL class properties dynamically.

Seems I'm stuck with plain ol' getter methods for now.

I've ended up using the Java approach to property accessor methods (ie create a Set and Get) for cases where I need to invoke methods dynamically. All those method do is provide a wrapper that does RETURN this-object: or  this-object: = . The property itself has the real/complete implementation if one exists.

My thinking is that this apporoach lets me move to using dynamic p[roperties without having to move code from the Get into the get implementation (if you know what I mean).

-- peter

This thread is closed