Action Statement
Group multiple response definitions within one action statement.
begin [guarded|resumable] [BLOCK_NAME]
[RESPONSE_DEFINITION] ...
end [BLOCK_NAME]
guarded
Ignore all stimuli received outside of the specified block while the block is being executed. Selections will not be taken for objects that do not have responses within that block, no matter what level of nesting they occupy.
resumable
Leave the block in response to any stimulus outside the block and return to the block immediately after that response has been executed. ESL will first finish any current action statements in the block, then execute the actions in the response that caused the block to be left, and lastly return to the block and await a stimulus from within that block.
Resumable blocks cannot contain response to low memory or response to termination response definitions.
BLOCK_NAME
The identifier for a block.
RESPONSE_DEFINITION
A response definition.
Description
A begin BLOCK is an action statement that contains a group of response definitions. Using blocks, you can indicate when responses are appropriate and when they are inappropriate. You can define and use a block anywhere an action statement can be specified, including within action routines, loops, and conditional (if/else) action statements. The begin statement begins a block. The end statement ends a block. The response definitions must lie between the begin and end of the block.
Like other ESL identifiers, a block name must be unique within the program. If you specify an identifier name in the begin statement, you must also specify the identifier name in the end statement, exactly as in the begin statement. You can completely omit the identifier from the definition.
A response definition that is inside a block might itself contain another block as part of its set of action statements; these are called nested blocks. Nested blocks create a program that contains many levels of responses, ranging from the innermost block to the outermost.
All blocks defined within a subroutine must be guarded blocks.
Guarded blocks are not recommended for applications that must be able to respond at all times to requests from other programs, such as through Dynamic Data Exchange (DDE), APPC, or other cases in which the program must respond to external messages.
A guarded block can be left only by the explicit statements leave block, leave loop (if the guarded block is within a loop), exit, or response to low memory.
A guarded block cannot contain a response to low memory or a response to termination response definition. Specifying a response to termination in a guarded block does not result in an error message, but has no effect.
Before ESL processes any response in a block (except response to start), it checks and processes the operating environment message queue. Since this is so, you could use the following action routine to cause your application to briefly suspend execution of the current routine and process other operating environment requests, or to flush unwanted messages posted to your application:
action FlushMessageQ is
begin resumable
response to timeout -1
leave block
end
Note that it is possible to lose responses when entering a guarded block. For example, you define a dialog region that contains an entry field and a push button. In addition, the entry field triggers an on validation response that contains a guarded block. If the focus is on the entry field when a user selects the push button, ESL takes the on validation response, but it will ignore any push button response except one to start. In such a situation, the focus does not move to the push button until the on validation response completes.
To avoid this type of situation, use the EslQueryFocus( ) function at the end of the on validation response and use a switch statement to invoke the action that the push button would have triggered.
Example
response to line "start" from Remote
begin
...
end
response to item Plot_MC
begin FirstChoice
...
end FirstChoice
response to PlotTwice_PB
begin resumable Always
...
end Always
response to line from Remote
begin guarded
...
end
response to StartApplication_PB
start local MyApplication "myapp.exe"
begin guarded
response to line "Done" from MyApplication
leave block
response to line from MyApplication
add to MyTextRegion_TR
insert input "\n"
response to timeout 5
send "ERROR\n" to errorlog
leave block
end
See Also
leave block Action Statement
response to OBJECT Response Definition