Search code examples
constantsopenedgeprogress-4gl

Is it possible to create constants in Progress-4GL?


Good afternoon, Is it possible to create constants in Progress-4GL?

The same question has been asked here, but there the question is based on object oriented programming (which I'm not doing).


Solution

  • There is no constant keyword in ABL.

    The simplest way to create constant values is using static properties. These are available in any code, even procedural.

    class ConstantValues:
      define static public PI as decimal initial 3.14159 get.
    end class.
    

    You could add a private setter and do the assignment in the static constructor, instead of the initial value.

    If you can't or don't want to use this approach, you can use preprocessors. If you need these values shared then define the preprocessors in includes and use those in your programs (even classes).

    But that's - to me - more work than it needs to be if you're creating new constant values.