LASTKEY function

Returns, as an INTEGER value, the integer key code of the most recent event read from the user (that is, from the keyboard or mouse) during an interaction with a procedure.

Note: Does not apply to SpeedScript programming.

Syntax

LASTKEY

Example

In this procedure, the user can move through the Customer file and update certain fields in each of the Customer records. The GO-ON option tells the procedure to continue on to the following statements if the user presses F9, F10, or F12. To determine what action to take, the LASTKEY function compares the key code of the last key pressed with the key codes F9, F10, and F12.

r-lastky.p

DISPLAY "You may update each customer. After making your changes," SKIP
  "Press one of:" SKIP(1)
  KBLABEL("GO") "Make the changes permanent" SKIP
  KBLABEL("END-ERROR")  "Undo changes and exit" SKIP
  "F9" SPACE(7) "Undo changes and try again" SKIP
  "F10" SPACE(6) "Find next customer" SKIP
  "F12" SPACE(6) "Find previous customer"
  WITH CENTERED FRAME instr.

FIND FIRST Customer.

REPEAT:
  UPDATE Customer.CustNum Customer.Name Customer.Address Customer.City 
    Customer.State GO-ON(F9 F10 F12) WITH 1 DOWN.
       IF LASTKEY = KEYCODE("F9")  THEN UNDO, RETRY.
  ELSE IF LASTKEY = KEYCODE("F10") THEN FIND NEXT Customer.
  ELSE IF LASTKEY = KEYCODE("F12") THEN FIND PREV Customer.
END.

Notes

See also

READKEY statement