fgl_getkey() waits for a key to be pressed and returns the integer code of the keystroke that the user makes. The function can take an optional argument, which is an INTEGER value for a timeout period, measured in seconds.
If the timeout is specified, then the function will return the INTEGER value of the keypress made within the timeout period. If no keypress is made within the timeout period, the function will return 431.
Every 4gl program must include some user interactions.
If your 4gl program doesn't have any user interactions, it will be performed at runtime and close immediately - without visible actions (like opening windows or forms, etc.) except for console displays.
Unlike fgl_lastkey(), which can return a value indicating the logical effect of whatever key the user pressed, fgl_getkey() returns an integer representing the raw value of the keystroke that the user makes.
fgl_getkey() recognizes the same codes for keys that the fgl_keyval( ) function returns. Unlike fgl_keyval(), which can only return keystrokes that are entered in 4GL forms, fgl_getkey() can be invoked in any context where the user is providing keyboard entry.
Here is an example of a program fragment that calls both functions, so that fgl_keyval() evaluates what fgl_getkey() returns.
MAIN
DEFINE key_press int
LET key_press = 0
OPEN WINDOW w_test WITH FORM "fgl_key_form"
WHILE key_press != fgl_keyval("escape")
LET key_press = fgl_getkey()
DISPLAY fgl_keyname(key_press) TO f_key
END WHILE
CLOSE WINDOW w_test
END MAIN
DATABASE formonly
SCREEN
{
*** FGL_GETKEY() Example ***
Press ACCEPT button to start
reading its value or
press Escape to quit.
You have pressed: [f001 ]
}
ATTRIBUTES
f001=formonly.f_key;