SENDKEY Function

RAMP-TS

SENDKEY Function

Emulates the pressing of a key.

Syntax

SENDKEY(sKeyName, oPayload)

Parameters

SKeyName

Required.String that contains the name of the key. See Function Key Names for SENDKEY Function.

oPayload

Optional. Object that is passed with the function.

 

Return Value

None

Remarks

This function typically initiates an asynchronous 5250 server side operation. Your RAMP-TS script(s) should end all processing immediately after invoking this function and then do nothing more until the asynchronous operation completes.

The completion of the asynchronous operation is typically indicated by the execution of the arrival script of the resulting 5250 screen display.  (Any queued script functions should be queued prior to executing this script function).

 

Examples

 

SENDKEY(KeyEnter);

  

The next example shows how to use the Payload Parameter with the SENDKEY and Q_SENDKEY functions.

An object is created and loaded with values in the Enter key BUTTONCLICK event and then the object is passed as the oPayload parameter of the SENDKEY function:

   /* ====================================================== */
   /* ==================  BUTTONCLICK  ===================== */
   /* ====================================================== */
   /* sButton: The button that was clicked */

 

   vHandle_BUTTONCLICK: function(sButton)
   {

 

     var bReturn = true;

 

     if (HANDLE_PROMPT()) return(bReturn); /* If the focus element is automatically prompted finish now */

 


     /* <BUTTONCLICK /> - Do not remove or alter this line */

 

           /* Handle function keys and buttons */

 

           switch (sButton)
        {
           case KeyEnter:
             var objEmp = new Object();
                 objEmp.strEmpno = GETVALUE("empno");
                 objEmp.strGName = GETVALUE("givename");
                 objEmp.strSName = GETVALUE("surname");
                 SENDKEY(KeyEnter, objEmp);
                 break;
           case KeyF3:
                 SENDKEY(KeyF3);
                 break;
           case KeyF4:
                 SENDKEY(KeyF4);
                 break;
           case KeyF12:
                 SENDKEY(KeyF12);
                 break;
           case KeyF14:
                 SENDKEY(KeyF14);
                 break;
           case KeyF21:
                 SENDKEY(KeyF21);
                 break;
           case KeyF22:
                 SENDKEY(KeyF22);
                 break;
              default:
                 SENDKEY(sButton);
                 break;
        }


     return(bReturn);
   },


 

Then the vHandle_Arrive function of the resulting screen gets the values from the payload if one is passed:

    /* ====================================================== */
   /* ==================  vHandle_ARRIVE  ================== */
   /* ====================================================== */
   /* Handle arrival at this Destination */
   /* oPayload: The payload supplied by the event initiator */
   /* oPreviousForm: Reference to previous object Form*/

 

   vHandle_ARRIVE: function(oPayload, oPreviousForm)
   {
     var bReturn = true;

 

     SHOW_CURRENT_FORM(true); /* Show the form in the framework and show VLF buttons */
     HIDE_5250_BUTTONS();     /* Hide any 5250 style buttons displayed               */
     GET_FORM_MESSAGE(22);    /* Extract messages and hide the message line          */
     SETBUSY(false);          /* Last thing done - turn off the busy state           */

 

     /* if there is something in the payload */
     if (oPayload != null)
     {
        ALERT_MESSAGE("Employee Details from the payload are: Employee Number: ", oPayload.strEmpno,"Name: ", oPayload.strGName, oPayload.strSName);
     }

 

     /* <ARRIVE /> - Do not remove or alter this line */

 

     return(bReturn);
   },