PreviousNextIndex

READKEY statement

Reads one keystroke from an input source and sets the value of LASTKEY to the keycode of that keystroke. Use the READKEY statement when you want to look at each keystroke a user makes and take some action based on that keystroke.

Note: Does not apply to SpeedScript programming.
Caution: If you are executing the READKEY statement while blocking on a .NET main form, a user action can unconditionally shut down the ABL application. For more information, see the WAIT-FOR statement (.NET and ABL) reference entry.
Syntax

READKEY [ STREAM stream | STREAM-HANDLE handle ] [ PAUSE n ] 

STREAM stream
STREAM-HANDLE handle
PAUSE n
Example

In the following procedure, when the user presses a key, the READKEY statement reads the keystroke and stores the character code value of that key (the key code) as the value of LASTKEY. The CHR function converts the character code value into a character value. If the character value is a Y, the AVM deletes the Customer. KEYFUNCTION determines the function of the LASTKEY. If that function is END-ERROR, the AVM exits the block, ending the procedure.

r-readky.p
FOR EACH Customer: 
  DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.City  
    Customer.State WITH 1 DOWN. 
  MESSAGE "If you want to delete this customer, press Y". 
  MESSAGE "Otherwise, press any other key.". 
  READKEY. 
  IF CHR(LASTKEY) = "Y" THEN DELETE Customer. 
  ELSE IF KEYFUNCTION(LASTKEY) = "END-ERROR" THEN LEAVE. 
END. 

Notes
See also

DEFINE STREAM statement, LASTKEY function, Stream object handle


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex