Ask Reuben

Difference Between MESSAGE and ERROR

Why does the MESSAGE text remain?

How to make the MESSAGE disappear?

A common misunderstanding is that apart from something to indicate severity, is that MESSAGE and ERROR have the same properties.

They differ in when they disappear having displayed their text to the user.

  • An ERROR will disappear at the next user interaction.
  • A MESSAGE will remain for longer and disappear when the window is closed or is overridden with the next MESSAGE.  For that reason you may see MESSAGE “” in your code to make the message disappear.

With the example code at the end of the article, click Message, Error, then Action.  When you click Action (the next user interaction), the Error tile disappears whilst the Message tile remains.

Click the Clear Message After 3 button to see the message tile removed programmatically with MESSAGE “”

This screenshot is after clicking Message, then Error to make both tiles appear at once.


This difference also manifests itself in the AUI Tree.  If you inspect the AUI Tree, For a MESSAGE you will see a Message node with type=Message as a child of the current Window node.  For an ERROR you will a Message node with type=Error as a child of the User Interface node.  (Yes it is confusing both Node names being ‘Message’ and the Type attribute being used to differentiate )

Other things to note about MESSAGE and ERROR…

  • If you want to force a user to acknowledge a MESSAGE or ERROR, use FGL_WINMESSAGE, or create your own dialog using MENU  …(STYLE=”dialog”).
  • With GBC Customisation, you can apply a theme variable so that the MESSAGE or ERROR tile can disappear after a certain time.  Refer to $theme-message-display-time and $theme-error-display-time.
  • Historically ERROR also used to emit a beep whilst MESSAGE did not.
  • Note the Presentation Styles you can also apply and that the applicable selector is Message:message and Message:error, this Message selector being tied into the node name in the AUI Tree.

Code example used for screenshots:


#! askreuben163.4gl
MAIN
    
    MENU ""
        BEFORE MENU
            CALL ui.Window.getCurrent().setText("Ask Reuben 163")
        COMMAND "Message"
            MESSAGE "Message " || CURRENT HOUR TO SECOND

        COMMAND "Error"
            ERROR "Error " || CURRENT HOUR TO SECOND
            
        COMMAND "Action"

        COMMAND "Clear Message After 3"
            MESSAGE "3"
            CALL ui.Interface.refresh()
            SLEEP 1

            MESSAGE "2"
            CALL ui.Interface.refresh()
            SLEEP 1

            MESSAGE "1"
            CALL ui.Interface.refresh()
            SLEEP 1

            MESSAGE "" -- clear message

        COMMAND "Exit"
            EXIT MENU
    END MENU
END MAIN