JavaScript Editor js editor     Web development 

Main Page

Simulates the key press associated with the ASCII character number specified by charNum.

void _EdSendKey(WHANDLE wh, int charNum)
WHANDLE wh;            /* Handle of editing window. */
int charNum;               /* Number of character. */


The following example opens for editing a file specified by a parameter. It inserts a line of text, "Hello, World", by sending the individual characters with _EdSendKey(В ). It then uses _EdSendKey(В ) to send a carriage return and linefeed and to insert an ASCII escape character. Notice that the escape character isn't interpreted as "discard editing session."

Visual FoxPro Code

В Copy Code
= SENDKEY("x")

C Code

В Copy Code
#include <pro_ext.h>

void putLong(long n)
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = 10;


FAR Example(ParamBlk FAR *parm)
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))

   WHANDLE wh;
   EDENV EdEnv;

   if (!_SetHandSize(parm->p[0].val.ev_handle,
      _Error(182); // "Insufficient memory"
   pFILENAME[parm->p[0].val.ev_length] = '\0';

   wh = _EdOpenFile(pFILENAME, FO_READWRITE);

   // Insert a line of text using _EdSendKey()
   _EdSetPos(wh, 0);
   _EdSendKey(wh, 'H');
   _EdSendKey(wh, 'e');
   _EdSendKey(wh, 'l');
   _EdSendKey(wh, 'l');
   _EdSendKey(wh, 'o');
   _EdSendKey(wh, ',');
   _EdSendKey(wh, ' ');
   _EdSendKey(wh, 'W');
   _EdSendKey(wh, 'o');
   _EdSendKey(wh, 'r');
   _EdSendKey(wh, 'l');
   _EdSendKey(wh, 'd');
   _EdSendKey(wh, '.');
   _EdSendKey(wh, 0x0d); // carriage return
   _EdSendKey(wh, 0x0a); // line feed
   _EdSendKey(wh, 0x1b); // esc char code is inserted in file

FoxInfo myFoxInfo[] = {
   {"SENDKEY", (FPFI) Example, 1, "C"},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

See Also

JavaScript Editor js editor     Web development