Enhance reflection functionality to get initial value of variable/property - OpenEdge Development - Products Enhancements - Progress Community

 OpenEdge Development

Enhance reflection functionality to get initial value of variable/property

It can be useful to get the initial value of a value/property after the value has been changed.

The Progress.Lang.Variable:Get() method could get enhanced to be able to return the initial value of the variable/property.

If that information is not available in the r-code, a compiler enhancement might be needed.

Comments
  • Hi Lieven:

    The ABL Reference contains a section on Data types.  This section contains a table which identifies the ‘Default ABL data type initial values and display formats’ (Table 23).  I believe this is the information you are requesting via this enhancement request.  If that is the case, why do you require the ABL to be able to provide this information dynamically via reflection?  Can you explain your use case for this feature?  I do not believe that other languages provide this information via their reflection APIs.  Thanks for clarifying your need for this capability.

  • Hi Evan,

    I don't want to get the default value of a data type, I want to get the initial value of a variable/property.

    DEFINE VARIABLE MyInt AS INTEGER NO-UNDO INITIAL 42.

    I would want to get the value 42 of MyInt even after it has been changed by code.

  • Thanks for the clarification.

  • Hi Lieven:

    Can you provide an example of how you would use such a facility?  Do you believe that this capability would be available only after the class was instantiated, or do you expect to use this facility to inspect a class prior to the application instantiating it?

    To assist Product Management in analyzing this request, it would be helpful to know if other customers also require this facility.

  • Hi Evan,

    In our case it would suffice to have this capability once a class in instantiated, but I can see benefits/posibilities before instantiation as well...

    The actual use case in which we need this is as follows:

    We have a dialog showing some fields:

    Eg. User query dialog:

       - User type (combo box with options 'Batch' and 'Interactive')

       - Active (combo box with options 'Yes', 'No' and '?' (all users))

    We have a simple data object with the following properties:

       - UserType (Enum, options UserType:Interactive and UserType:Batch)

           Initial value can't be set through INITIAL for class/enum types so this might be a problem already.

           We set the initial value in the constructor.

       - Active (Logical, INITIAL TRUE)

    We can pass the data object to the UI, which will call a routine to populate the fields in the UI with the values from the data object using reflection (the names of the fields correspond to the name of the object's properties).

    The user can change the values in the UI and press Apply which updates the value in the data object and publishes an event which can then be caught by other UI to e.g. reopen a query using these settings.

    -> There is also a Reset button which should repopulate the values on screen with the original (initial) values of the data object.

    -> In order to do that now we need to store the initial values somewhere, either in extra properties (UserTypeInitial, ActiveInitial), a temp-table or some other means...

    -> It would be useful if we could get the property's initial value using reflection instead of having to keep it in a separate variable/temp-table.

    Since you can't specify the INITIAL attribute on class based variables/properties, adding that functionality to class based properties/variables might be a pre-requisite (or it must be define what we mean by 'initial value' in those cases).

    Hope this makes it somewhat clearer...

  • Hi Lieven,

    can't you just pick them up using reflection:

    def var Instance as Progress.Lang.Object no-undo.

    def var cProperty as character no-undo.

    Instance = .

    cProperty = ""

    Instance:GetClass():GetProperty(cProperty):Get(Instance). /* will return the current value of the property */

    Similar functionality exists for variables.

  • some text was omitted:

    Instance = .your-object-reference

    cProperty = "your-property-name"

  • @WJCPvanBeek: No, I need the initial value, not the current value. Have a look at the previous replies/discussion to get a better view.