When ESL receives text from an application program or the keyboard, it searches for a valid response to char or response to line response definition. ESL first searches in the innermost active block. (If blocks are not specified in the program, ESL searches the entire program and takes the first valid response definition.) As soon as a response corresponding to the input is found, that response is taken immediately.
Consider the following example:
begin
response to line from keyboard
...
response to char "AB" from keyboard
...
response to char "A" from keyboard
... end
If the input from the keyboard consists of the string:
"AB\n"
then ESL takes the third response:
response to char "A"
...
as soon as it receives the "A", without waiting to see if anything follows. When ESL receives the rest of the line:
"B\n"
it takes the first response:
response to line
Note that the response is observed only within the innermost active block. Consider the following:
begin BlockA
response to BlueKey
begin BlockB
response to line from App
...
response to char "AB" from App
...
end BlockB
response to char "A" from App
... end BlockA
In this example, assume that you are in Block B. No response is taken when ESL receives the "A". When ESL receives the "B", it takes the second response:
response to char "AB" from App
ESL attempts to satisfy the innermost block until it has recognized enough input to determine that none of the inner responses can be satisfied. In the example above, suppose that the response to line statement was missing and the input was "AC\n". Because ESL has determined that there is no "AB" in the line, it takes the outer response, matching the "A".
If ESL does not find a match between any response definition statement and the current input, even after searching all active blocks, the current input is discarded. If ESL does find a match, it performs the action statements specified in the response definition.