Search code examples
colorsopenedgeprogress-4gl

Does Progress-4GL have color constants?


In my application, I need to modify the colour of a widget.

When I look into my application, I see following lines of code:

BGCOLOR 25 FGCOLOR 24 .
BGCOLOR 21 FGCOLOR 20 .
BGCOLOR  8 FGCOLOR 24 .
... (and many more)

This is, of course, very unreadable.

Does Progress-4GL have any colour constants, like clRed, clGreen, ..., I can use for readability reasons? In case not, is there any online "cheat sheet" for this subject?

Thanks


Solution

  • For readability use either enum or preprocessors to define what your intended colors are based on how you have defined your colors in your ini file or registry.

    // color.cls
    enum color:
    
       define enum
          black       = 0
          dark-blue   = 1
          dark-green  = 2
          dark-cyan   = 3
          dark-red    = 4
          dark-purple = 5
          
          // ...      
          
          white = 15
          .
    
    end enum.
    

    Unfortunately the enum is not automatically cast to its integer value when needed for fgcolor:

    define frame fr
    with
       bgcolor integer( color:dark-purple )
       .
       
    view frame fr.
    wait-for close of frame fr.
    

    With preprocessors this is a bit simpler:

    // color.i
    &global define color-black        0
    ...
    &global define color-dark-purple  5
    &global define color-white       15
    

    And then use them:

    { color.i }
    
    define frame fr
    with
       bgcolor {&color-dark-purple}
       .
       
    view frame fr.
    wait-for close of frame fr.