Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - keyboard() stuff the keyboard buffer with a string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 keyboard()          Stuff the keyboard buffer with a string
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   proc keyboard extern
   param const char cString

 Arguments
   cString is the string to place in the keyboard buffer.

 Return
   None.

 Description
   The keyboard() procedure stuffs the keyboard buffer with cString.
   Force maintains its own keyboard buffer. It is this buffer, not the BIOS
   keyboard buffer, which retrieves the characters from the keyboard
   procedure, i. e. you cannot use this proceedure to "stuff" keycodes to DOS
   before leaving the Force application.

   The command clear typeahead clears all pending keystrokes from the
   keyboard buffer.

 Example
   #define EXAMPLE_IO
   #include example.hdr

   func int FilterFunc
   if lastkey() == K_F2      // if F2 pressed
      return K_C_W           // convert it to a get ending character
   endif
   return lastkey()
   endfunc
   
   proc Test_keyboard
   vardef
      char( 20 ) cName
   enddef
   clear
   // Use keyboard and keyint in combination
   keyboard( "Veronica" )
   keyint( K_ENTER )
   accept "Give me a string... " to cName
   ? cName                             // output: "Veronica"
   wait
   // Force termination of a get whenever the user presses F2
   @ 10, 10 say "Press F2 to save"
   @ 12, 10 say "Name: " get cName filter FilterFunc()
   read
   ? cName
   wait
   endproc

   proc main
   Test_keyboard()
   endproc

See Also: clear typeahead keyint()

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