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 - waitkey() delay execution unless key is pressed http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 waitkey()           Delay execution unless key is pressed
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   func uint waitkey extern
   param value uint uMilliSecs

 Arguments
   uMilliSecs is the number of milliseconds to wait.

 Return
   The code of the keypress that interrupted the wait state.

 Description
   This function is similar to delay() except delay times are defined as
   multiples of milliseconds instead of seconds.

 Example
   #define EXAMPLE_IO
   #include example.hdr

   dbfdef sTest
      char( 10 ) fchar
   enddef
   
   func logical RecLock
   para value dbl eWaitTime
   // Try to lock a record - if the lock fails, wait .5 seconds
   // and try again until the specified tota wait_time has been exceeded
   vardef
     logical lForever
   enddef
   if rlock()
      return( .T. )
   endif
   lForever := ( eWaitTime == 0.0 )
   do while lForever .or. eWaitTime > 0
      if rlock()
         return( .t. )
      endif
      waitkey( 500 )
      eWaitTime -= 0.5
   enddo
   return( .F. )
   endfunc
   
   proc Letters
   vardef
      uint n
   enddef
   ? "Printing letters..."
   ?
   for n := 'a' to 'z'
      ?? chr( n )
      waitkey( ( n - 'a' ) * 20 )       // wait more and more
   next
   wait
   endproc
   
   proc Test_waitkey
   Letters()
   build "stest.dbf" from alias sTest
   open sTest shared
   append blank
   if RecLock( 10 )
      sTest->fchar := "Success"
      ? sTest->fchar
   else
      ? "Record lock failed"
   endif
   close sTest
   erase "stest.dbf"
   endproc

   proc main
   Test_waitkey()
   endproc

See Also: delay()

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