Monday, 21 May 2012

Undocumented feature - images in dropdowns

As with any language, Uniface has some undocumented features.  Sometimes these are features that were developed but never fully supported for one reason or another, or sometimes the documentation was just forgotten along the way.  It can be risky using these features sometimes, as you never know if the functionality might be completed, changed or removed, and as it's not documented, you don't really have a leg to stand on.

Having said that, here is a nice but non-essential undocumented feature in Uniface - images in dropdowns.  The client application can be a little old-fashioned looking at times, although a lot can be done to improve this is the you have the time to fiddle with the settings.  Images in dropdowns do make it look a little more user-friendly though, I think.

It's easy to do in Uniface, but definitely "hacky".  When you set the valrep of the dropdown you might currently do it something like this...

$valrep(field) = "val1=Rep 1·;val2=Rep 2"

...which will display a dropdown list with two values in, "Rep 1" and "Rep 2".  If you want to add images, then you simply need to add the image at the beginning of each list item, but delimited with a gold-not instead of a gold-semi, like this...

$valrep(field) = "^img1·!val1=Rep 1·;^img2·!val2=Rep 2"

...and hey presto, images will appear.  These images can be in any of the following formats...

  • ^glyph - glyphs need to be compiled into UOBJ (always available and performs well).
  • @filename - images loaded from a fileserver (not always available and performs badly).
  • #fieldname - images loaded from a BLOB field in the database (always available and performs ok).
  • &url - images from the web (only works in server pages - not applicable for this).

Here is an example, just to prove it...

Summary: It is possible to display images in a dropdown in the client application, but it is undocumented and therefore unsupported.


  1. This is documented but a bit hard to find.
    Search for ValRep List Syntax.
    Here is documented that you can use images in ValRep lists, but unfortunately it only mentions Glyphs:
    Please feel free to use the feedback link that is on the bottom of each help page to communicate this oversight to Compuware.

    Glyphs in ValRep Lists
    Although it is common to use text in ValRep lists, in list box and drop-down list widgets, it is also possible to use glyphs in the Representation. When both glyphs and text are used, the GOLD ! is required as the subfield separator. Use the following syntax:

    ValRep = Value = GlyphName ! Representation { ; Value = GlyphName ! Representation }

    For example, the following Proc code produces a list showing the Uniface icons (although the list has been abbreviated) :

    $fieldvalrep(listbox)="a=^U7_ENTANA !Initial Data (Entities) ;b=^U7_DTDSTD !DTDs·;c=^U7_MSCSTS !Startup Shells"
    In this case, each Representation consists of a glyph and text. The GOLD ! is used as a subfield separator.

    Note: Glyphs are not displayed when a dynamic drop-down list does not have the focus.

    Then in the section "Image Handling" the whole thing with ^Glyph, @FileName, #FieldName, &URL is explained.

  2. Yes, a colleague of mine told me that this is documented from Uniface 9.5 onwards, which is good.