Please enable JavaScript to view this site.

ESL Documentation

Navigation: ESL Documentation > ESL Programmers Reference > Response Defintions

response to char and response to line

Scroll Prev Top Next More

Response Definitions

Respond to input from applications or the keyboard.

[interrupt] response to {char|line}

[[col NUM1 [thru NUM2]] {STRING|word|number|blank}] ...

from {keyboard|APPLICATION}

[ACTION_STATEMENT] ...

interrupt

Allow ESL to leave and return to any block currently executing, except a guarded block, when the response is stimulated. ESL will first finish any current action statements from a response in the block, then execute the actions in the interrupt response, and finally return to the block to await a new stimulus from within the original block.

response to char

Trigger the specified response when specified character(s) are received from the keyboard or from a local or remote application program. The input need not end with a newline character.

In a response to char response statement, the input function returns the characters starting at column 1, up to and including the character that resulted in the match. ESL begins further examination at the next column position, which is now called column position 1.

response to line

Trigger the specified response when a complete line of input is received from the keyboard or from a local or remote application program. ESL considers a line to be any stream of characters that ends with a newline (linefeed) character.

In a response to line statement, the input function returns the entire line. The next line examined for a match begins with the first column position following the newline character.

col NUM1

The exact column position in which the first character of the specified input must appear.

col NUM1 thru NUM2

The range of column numbers in which all the characters in the specified input must appear.

NUMn

A compile-time integer value in the range 1-254, representing a column position in the input stream.

STRING

Any compile-time string value that must appear in the input. The string must be a literal (in quotation marks) or a string constant. The string must be contiguous.

word

A word must appear in the input. A word is any contiguous group of ASCII characters, including digits but not including blanks, control characters, or delete characters.

number

A number must appear in the input. A number is a decimal integer, consisting of any digits, optionally preceded by a sign (+ or -) or leading blanks. Embedded blanks, commas, and decimal points are not allowed in numbers. Note that floating point numbers are not taken.

blank

A blank character must appear in the input.

from keyboard

Respond to character input from the keyboard. (See Keyboard Mapping Table .)

APPLICATION

An identifier for the application program from which a line of input is received.

ACTION_STATEMENT

An action statement.

Description

When you use a response to char response statement in a block, be careful to ensure that ESL knows when no more information is expected, so that all available responses--including those outside the block can be taken. In order to check for a pattern match in an outer block, the pattern in the inner block must not be matched. When you use response to char, the only way to do this is by using a specific pattern match that excludes any other input. And in order to make sure that all available responses can be taken, use the col specification in the match clause.

Specify response to line rather than response to char whenever possible, to increase processing efficiency.

You can specify as many match clauses as you wish in a response to char or response to line statement. The response will be invoked when the input received by ESL matches every match clause specified for that response. The match clause can specify a particular character string, a blank, any word, any integer number, or any combination of these.

When a pattern is matched and the response definition is invoked, all characters up to and including the matched pattern are removed from the input stream and copied to the built-in function input. Further pattern matching will begin at the next character in the input stream; this character position becomes column 1 of the input stream.

If more than one such response definition is found, the first response definition satisfied is invoked, even if there are other responses earlier in the block that would be satisfied if more of the input were received before responding.

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.

Not all key combinations generate keyboard input (see Keyboard Mapping Table).

A response to char or response to line from keyboard cannot be taken while in a dialog box or dialog region.

Example

response to line from SalesApp

...

response to char from keyboard

...

response to line col 1 "?" from keyboard

make Help visible

response to char col 1 "+" from Database

...

response to line col 1 ">" col 3 thru 8 number from Query

...

See Also

input Response Inquiry Built-in Function

Keyboard Mapping Table