A block is an ESL 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 multiple responses to the same stimulus, wherein under certain circumstances ESL would take one response, while under other circumstances ESL would take a different response.
A block might be active or inactive.
•If a block is active, the responses defined within it can be triggered by appropriate stimuli.
•If a block is inactive, the responses defined within it are not taken, even if the relevant stimuli occur.
Like other action statements, a block can be specified within a response definition or an ESL action routine 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.
All blocks defined within a subroutine must be guarded blocks.
An example of a block is shown below. In this example, as soon as the application receives a "Go \n" message, it sends lines of text to ESL, which displays them on the monitor. When the application is finished, it sends the character ">" to ESL, which then exits the block.
begin # Begins block.
# Response to entering block:
response to start
send "Go \n" to RemoteA
# Response to receiving character ">" from application:
response to char col 1 ">" from Remote
leave block
# Response to receiving a line of text from application:
response to line from RemoteA
add to TRegion
insert input "\n"
end # Ends block.
As long as a block is active, its responses can be taken over and over again, until the block is exited. The leave block statement, described in Leaving (Exiting) a Block, allows ESL to explicitly exit a block. There are circumstances under which ESL leaves a block without this statement; these are also discussed below.