# PUSHKEY

Syntax:

Then: PUSHKEY "c"

Then: PUSHKEY "[code]"

Then: PUSHKEY "abc[code]xyz[code]..."

Then: PUSHKEY exp

c = character(s)

[code] - Special Keys (those returned by @sk, like "[ENTR]" or "[SAVE]" or "[CRUP]").

exp - The argument to PUSHKEY can be an expression that resolves to keyboard codes and characters.

Version Ref: 4.0

Description:

Places "keystrokes" into the keyboard queue as if they were pressed by the user.

Examples:

@keyP If:

Then: PUSHKEY "u[CDWN][CDWN]33[ENTR]open[SAVE]" ; end

The above code will put users into UPDATE mode, move the cursor down two fields, type the number "33", press ENTER, type the word "open" and then press the SAVE key for them. With one keystroke, the user performs many keystrokes.

Note: Two things are important to understand about how PUSHKEY operates. First, the programmed sequence of keystrokes happens from exactly where the cursor is positioned when the next END statement is reached. Second, nothing happens until that END statement is reached, and then the PUSHKEY executes.

Examples:

To run an extended selection set called "new," before any records are updated. You could use PUSHKEY in your @ENTSEL processing as follows:

Then: pushkey "X22Lnew[ENTR][ENTR]"; end

"X" Exits from the current record.
"2" Selects The "scan For Records" option from the Inquire, Update, Add, menu.
"2" Selects the "Extended Selection" option from "Scan For Records" submenu.
"L" Loads a selection set.
"new" Inputs the name of the selection set.
"[ENTR]'' Inputs the four-letter special key code for a < RETURN >, to enter the selection set name.
"[ENTR]'' Inputs the four-letter special key code for a < RETURN > to execute the selection and retrieve the records.
"end" Ends the @ENTSEL when-processing

PUSHKEY accepts "[BRKY]". When PUSHKEY puts "BRKY" into the Inquire, Update, Add buffer, it performs as though the BREAK key was pressed. The following example shows how to use this feature to prevent anyone from updating or adding records:

@update If:
Then: errorbox "update not allowed."
If: @OS = "DOS"
Then: pushkey "[BRKY] " ; screen; end
Then: pushkey "[BRKY][BRKY]" ; screen ; end

Note: Remember that @UPDATE must use the SCREEN command. Using @keyU would not prevent records from being added through "Add Records" mode. Also, in "Add Records" mode, "[BRKY][BRKY]" will prevent a blank record from being created.