Progress
Language Reference


KEYFUNCTION Function

Interfaces
OS
SpeedScript
All
All
No

Evaluates an integer expression (such as 301) and returns a character string that is the function of the key associated with that integer expression (such as GO).

SYNTAX

KEYFUNCTION ( expression ) 

expression

A constant, field name, variable name, or expression whose value is an integer key code.

EXAMPLE

This procedure displays a menu and highlights different selections, depending on which key you press. On the first iteration of the REPEAT block, the COLOR statement tells Progress to color msg[i] with the same color used to display messages. Because the initial value of i is 1, msg[i] is the first menu selection. Therefore, the first menu selection is colored MESSAGES.

r-keyfn.p
DEFINE VARIABLE msg  AS CHARACTER EXTENT 3.
DEFINE VARIABLE i    AS INTEGER INITIAL 1.
DEFINE VARIABLE newi AS INTEGER INITIAL 1.
DEFINE VARIABLE func AS CHARACTER.

DISPLAY "     Please choose     " SKIP(1)
   " 1  Run order entry    " @ msg[1] ATTR-SPACE SKIP
   " 2  Run receivables    " @ msg[2] ATTR-SPACE SKIP
   " 3  Exit               " @ msg[3] ATTR-SPACE SKIP
   WITH CENTERED FRAME menu NO-LABELS.

REPEAT:
  COLOR DISPLAY MESSAGES msg[i] WITH FRAME menu.
  READKEY.
  func = KEYFUNCTION(LASTKEY).
  IF func = "CURSOR-DOWN" AND i < 3
  THEN newi = i + 1.
  ELSE IF func = "CURSOR-UP" AND i > 1
  THEN newi = i - 1.
  ELSE IF func = "GO" OR func = "RETURN"
  THEN LEAVE.
  IF i <> newi THEN COLOR DISPLAY NORMAL
    msg[i] WITH FRAME menu.
  i = newi.
END. 

See the example in the KEYCODE Function reference entry for details on what happens if you press keylabel component.

NOTES

SEE ALSO

KEYCODE Function, KEYLABEL Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095