Please enable JavaScript to view this site.

ESL Documentation

You can define a response for all of the objects that make up a class. In the following example, a confirmation message will be displayed if the user selects any key that is a member of the MenuKeys class:

 

response to MenuKeys

    make KeyMessage visible

 

In general, you want to group, into a class, objects for which the same response will be taken. Note, however, that you can specify individual responses for the individual objects in a class. In the following example, Help is a part of the class MenuKeys, but when Help is selected, only that individual response will be taken. Other members in the class MenuKeys will not be affected by the response.

 

response to Help

    make PanicMessage visible

    exit

 

Remember that ESL searches for responses in the program from top to bottom, from the current block through each outer block, in succession, and, if two responses exist for the same object, just the first one encountered will be executed. Thus, when an object is selected, the first relevant response will be executed; for example:

 

response to MenuKeys  # Help is a member of the

    ...               # class MenuKeys ...

 

response to Arrows    # ... and is a member of the class

    ...               # Arrows ...

 

response to Help      # ... and has a response of its

    ...               # own.

 

Because of the order in which these statements are written, only the response to MenuKeys response statement will be executed when the Help key is selected. You can control the order in which responses are taken by using blocks, described in Working with Blocks.

 

Often, you will want to specify a single response for an entire class of objects, but to vary slightly the actions that are performed for the objects that make up the class. One way to do this is to use the built-in functions parameter and object in the response definition for the class; this is described in Using Built-in Functions with Classes.