Description:
When user presses key "x" (or "X", case is not significant) while sitting at the "Enter Selection >" prompt.
@key can be used with any plain text character key on the keyboard. Special keys (TAB, ENTER, SAVE, etc.) are not usable with @key.
This processing can be activated by the user while sitting on a record with the cursor at the "Enter Selection" prompt (or custom prompt).
Pressing the designated key locks the record (multi-user), runs the AUTOMATIC table first, and then runs the @key processing, starting at its label following the table directions until an END is encountered. At this point, the AUTOMATIC table is run again and the process is finished.
IMPORTANT: The AUTOMATIC table's first job is to clear all regular dummy variables. If you set a variable inside your @key processing and expect it to retain that value, you must make this variable "global". The AUTOMATIC table does not clear global variables.
NOTE: Be sure that there is always a "then" line above your @key process which will not allow the INPUT table processing or other @when processing to "fall through" to this @key code. This will, of course, give you undesirable results. If there is no INPUT processing and you want to build an @key routine, put an END statement on line 1's "then" line, and build the @key starting from line 2. This way, when the user SAVE's the record, the @key process will not be run as if it were the INPUT table processing.
IMPORTANT: On multi-user and network systems, @key processing "locks" the current record. If other users are running reports or processing that select this record, they will be stopped in their tracks until the lock is removed. For this reason, you should not put up processing MENU's with @key. Also, be careful not to put up message boxes or the like, which require that the user press a key to bring them down. More likely than not, someone will inadvertently leave such a message on the screen and go to lunch. This hangs everyone else up who needs access to that record. A better idea would be to use the SLEEP command and display the message for a reasonable amount of time and then bring it down within your own @key code.
Example:
@keyT If:
Then: show "@The time is"<@tm ; end
The T is capitalized only for clarity when reading the code. (Processing tables are insensitive to cAsE.)
The above will certainly work, but it forces the user to press ENTER to finish the @key process. Instead, try:
@keyT If: 'on Unix, use sleep "3"
Then: show "The time is"<@tm ; sleep "3000" ; end
This will show the time for 3 seconds and then automatically end the processing, leaving nothing up to the user.
Of course, if the @key process is supposed to put the user into UPDATE mode so he can add to or modify the record or perform some other task, this is perfectly acceptable and a great use for @key processing. You have to assume that the user will finish such a task before leaving for lunch.
@key processing can be tricked into working from other parts of the INPUT processing table. This is done with PUSHKEY. As in:
Then: pushkey "T" ; end
When this code is encountered, filePro waits for control to be returned to the user, and just before it accepts input from the keyboard, it generates the designated key (in this case T). Since the @keyT is triggered by this event, it happens just as if the user had activated it himself. If there is no @keyT processing on the INPUT table, nothing will happen.
Note: @keyX trigger is used only on INPUT processing table.