INTERACTIVE FUNCTIONS
User-defined functions can display messages and/or request input from the key-
board. The messages (character data) in the user-defined function are enclosed in
quotes. The 0 (quad) and c] (quad quote) symbols are used to request input from
the keyboard during function execution. The following function is an example of
an interactive function that computes the amount of interest on a capital amount
for a given number of years:
I44
Requesting Keyboard Input during Function Execution
The 0 (quad) appearing anywhere other than immediately to the left of the assign-
ment arrow indicates that keyboard input is required. When the 0 is encountered
in the function, the two symbols 0: (a quad symbol followed by a colon) are dis-
played, the display is moved up one line, and the cursor appears. The quad and
colon symbols are displayed to alert the user that input is required. Any valid
expression entered at this point is evaluated and the result is substituted for the
quad. You can escape from a quad input request by entering the right arrow +.
An invalid entry in response to request for input results in an appropriate error
message and the request for input is made again. Any system commands entered
will be executed, after which the request for input will again be made. An empty
input (no keying) is rejected and the 5100 again displays the symbols 0: and
awaits input.
When the quad quote (3 (a quad overstruck with a quote) is used, input from the
keyboard is treated as character data. The input begins at the left margin of the
display; quotes do not need to be entered to define the data as character data.
When [I] input is requested, the symbols 0: do not appear as they did with a 0
input request. The input is entered after the flashing cursor appears on the screen.
For example:
x 4.. IJ
X
x 4- I3
x
CAN ' 'I'
CAN ' 7'
'CAN' "I"
' CAN ' "I' '
Anything you enter in response to a quad quote request for input is considered
character input. Therefore, if you enter a system command or a branch arrow
(-+I to terminate the function, the entry is treated as character data for the
function and the system command or branch will not be executed. This can be
a problem if you are trying to escape from a quad quote input request. There-
fore, APL provides an
escape for this situation. To escape from a quad quote
input request, enter the Osymbol by holding the CMD key and pressing the
key. The function is interrupted and the function name and the line num-
0
ber being executed are displayed. You can then modify the function or termi-
nate it by entering the right arrow +.
745
Previous Page Next Page