Unfortunately, flushing the queue leads to a couple of complications. ESL uses the information in the message queue to determine the values for certain functions. If the queue is flushed before those functions are executed, the information will not be available. This is the case for the Response Inquiry built-in functions such as object, ancestry and parameter (See the Online or Quick Reference Guide for a complete list of the those functions.) You can work around this by copying their values to variables before the flush and using the variables instead of the functions.
Subsequent responses are also lost. For instance, a response to push button may first trigger a response to entry field on validation If the queue is flushed in the validation response, the push button response will not execute. You can work around this by moving all of the code for the possibly lost response into an action routine or subroutine. Then in the first response that is triggered you could call the routine to complete the required processing.
Now since most dialogs have multiple objects which have responses, you need to know which routine to call. In each applicable response, save object to a variable, flush the queue, then check which object was touched and call the appropriate routine.