Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>set key</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
SET KEY


Syntax:     SET KEY <expN> TO [<procedure>]

Purpose:    To allow a procedure to be executed from any wait state when
            a designated key is pressed.

Arguments:  <expN> is the INKEY() value of the designated key.

            <procedure> is the name of the procedure that executes
            when the assigned key is pressed.  If <procedure> is not
            specified, the current key definition is released.

Usage:      After a key is redefined with SET KEY, pressing that key
            within a wait state executes the specified procedure passing
            three automatic parameters corresponding to: PROCNAME(),
            PROCLINE(), and READVAR().  The procedure and variable
            parameters are character while the line number is numeric.

            A maximum of 32 keys may be SET at one time.  At start-up,
            the system assumes that the F1 key is SET TO Help.  If there
            is a procedure linked into the current program, pressing F1
            from a wait state will execute it.

            SET KEY procedures should be designed so that they preserve
            the state of the application (i.e.. screen appearance,
            current database selection, etc.) and restore it before
            exiting.  CLEAR, for example, should be avoided, since it
            clears all pending GETs if issued during a READ.  CLEAR
            SCREEN can be used to clear the screen without affecting
            GETs.

            Precedence: SET KEY definitions take precedence over SET
            FUNCTION, SET ESCAPE, and SETCANCEL().

Library:    CLIPPER.LIB

----------------------------------- Example --------------------------------

   f2 = -1
   ctrl_y = CHR(25)
   home_key = CHR(1)

   SET KEY f2 TO Accounts
   USE Invoices
   SELECT 0
   USE Accounts
   SELECT Invoices

   @ 10, 10 GET Id
   READ

   RETURN


   PROCEDURE Accounts
   PARAMETERS proc, line, var

   IF var == "ID"
      DECLARE fields[1]
      fields[1] = "Company"

      SELECT Accounts

      SAVE SCREEN
      DBEDIT(10, 10, 18, 40, fields)
      KEYBOARD ctrl_y + ID + home_key
      RESTORE SCREEN

      SELECT Invoices

   ELSE

      TONE(100, 2)

   ENDIF

   RETURN


See Also: KEYBOARD SET FUNCTION LASTKEY() Keyboard codes

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson