Showing posts with label title. Show all posts
Showing posts with label title. Show all posts

Wednesday, 6 June 2012

Undocumented feature - filebox filter

I was working with Uniface's filebox command today, allowing a user to select a file using the Windows selection dialog.  This is a handy feature and very simple to use, it's fairly well documented, but there is one thing missing.


The easiest way to trigger this selection dialog is like this...



  filebox





The "All File (*.*)" option is added by default, and as far as I'm aware this cannot be removed.  However, it is normally useful to filter the files which appear, especially if it is being used to select a particular type of file.  You can add a filter like this...


  filebox "*.txt"






Notice that the title of the filter is built from the file extension in your filter - very clever.  You can even add multiple filters, like this...



  filebox "my*.txt·;*.txt"





However, In this example I have two different filters, but because they have the same file extension, the default titles are the same.  Well here's the undocumented bit; changing the title is very easy to do, like this...



  filebox "my*.txt=My text files·;*.txt=Text files"





Much better!  This allows you to create more user-friendly dialogs with helpfully named filters.

Summary: It is easy to rename the filters in a filebox selection dialog, if you know how.

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.