Thursday 31 May 2012

Undocumented feature - title in dialog

This is an undocumented feature which I believe is widely known, but I thought I'd write a quick post about it whilst I was thinking about undocumented features.


In Uniface it is very simple to prompt the user, either to show them a message which they must confirm, or ask them to select from a number of options by clicking on the relevant button.  It is done using the askmess command...


  askmess/warning "This is a warning","Ok"


The various switches can be used to control the icon and whether or not it beeps, etc - I won't go into these here as they are well documented.  This presents the user with a popup like this...




I've redacted the software name, but what you'll see if you try this, is that the title of the dialog matches the title of the application.  In many cases you will not want this, you'll want to specify your own title.  Luckily, this can be done, like this...


  askmess/warning "This is a warning~My own title","Ok"


Note that there is a tilda ("~") character in the middle of the first parameter, which separates the dialog text from the dialog title.  This presents the user with a popup like this...




A neat little trick and very simple.  If Compuware decide to take this out then we're going to have lots of dialogs with strange prompt text though!


It's worth noting when using the askmess command that this does not work in web forms, in fact it crashes the userver last time I tried it.  If you are created a web form that reuses some existing functionality from a client form, then do watch out for this.  In fact I'd recommend creating a global procedure which calls askmess and then always call this global procedure.  This allows you to put standard checks in for web forms (using $web) and handle this accordingly.  It should also allow you to fix all of your askmess statements in one go, should this undocumented feature be removed or changed in the future.


Thanks to Paul Koldijk for reminding me about this one... http://koldijk.com/uniface/askmess_titel.htm

Summary: It is possible to change the title of a dialog created with the askmess command.

No comments:

Post a Comment