Use the PROCESSMESSAGE command to process messages that are currently in the windows message queue.
It is helpful to show a progress message when performing long running tasks. When processing a time-consuming routine, there are ways to let the user know the status of the process using the PAUSE 3 with GAUGE options as well as the use of PROCESSMESSAGE command, which processes messages that are currently in the windows message queue. The PROCESSMESSAGE can help in the GUI part to avoid the "Not responding" behavior in Windows operating systems. A common use of PROCESSMESSAGE is in long WHILE loops.
PROCESSMESSAGE may be called in each loop iteration to give the GUI time to process the pending Windows messages. For a loop that only does data processing, PROCESSMESSAGE can also be used. It is advised to disable GUI update settings like UINOTIF before entering the loop with PROCESSMESSAGE, to counter some side-effects of PROCESSMESSAGE.
It is also important to not overuse PROCESSMESSAGE. Use the command only in places where it is necessary for the GUI to "breath" during a long running task.
PROCESSMESSAGE can be called after every iteration in the WHILE loop cycle. The following example demonstrates where to best place the PROCESSMESSAGE command.
When using the PAUSE command, the NO_FOCUS option can also be included in the OPTION parameters, so the dialog will not be focused when displayed. The no focus feature will benefit to possibly prevent an interruption in the focus transition in an active form.
Examples:
--Example 01 - PAUSE with Moving GIF:
SET VAR vPauseMessage TEXT = ((CHAR(013))+'Computing - Please Wait ......')
CLS
PAUSE 3 USING .vPauseMessage +
CAPTION ' Pause 3 with PROCESSMESSAGE' +
OPTION ICON_FILE Hourglass.GIF +
|BACK_COLOR WHITE +
|MESSAGE_COLOR WHITE +
|MESSAGE_FONT_NAME VERDANA +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 10 +
|THEMENAME R:BASE Rocks!
SET VAR vCounter INT = 1
WHILE vCounter < 2500000 THEN
SET VAR vCounter = (.vCounter + 1)
PROCESSMESSAGE
ENDWHILE
CLEAR VARIABLE vPauseMessage,vCounter
CLS
RETURN
--Example 02 - PAUSE with GAUGE:
CLS
PAUSE 3 USING ' Calculating ... Please Stand By ...' +
CAPTION ' Pause 3 with Gauge + PROCESSMESSAGE' ICON APP +
OPTION GAUGE_VISIBLE ON +
|GAUGE_COLOR [R218,G228,B246] +
|GAUGE_INTERVAL 10 +
|MESSAGE_FONT_NAME VERDANA +
|MESSAGE_FONT_SIZE 10 +
|MESSAGE_FONT_COLOR BLUE +
|THEMENAME Razzmatazz
SET VAR vCounter INTEGER = 1
WHILE vCounter < 2500000 THEN
SET VAR vCounter = (.vCounter + 1)
PROCESSMESSAGE
ENDWHILE
CLEAR VARIABLE vCounter
CLS
RETURN
--Example 03 - PAUSE with GAUGE and NO_FOCUS:
CLS
PAUSE 3 USING 'Collecting data ... this will take a few seconds ...' +
CAPTION 'Using Pause with Gauge' ICON WINDOWS +
OPTION BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR NAVY +
|MESSAGE_FONT_SIZE 12 +
|GAUGE_VISIBLE ON +
|GAUGE_COLOR GRAY +
|GAUGE_INTERVAL 10 +
|NO_FOCUS
SET VAR vCounter INTEGER = 1
WHILE vCounter < 250000 THEN
SET VAR vCounter = (.vCounter + 1)
PROCESSMESSAGE
ENDWHILE
CLEAR VARIABLE vCounter
CLS
RETURN