home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18155 < prev    next >
Encoding:
Text File  |  1993-01-05  |  2.0 KB  |  50 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!jamie
  3. From: jamie@cdevil.unx.sas.com (James Cooper)
  4. Subject: Re: Simple C question
  5. Originator: jamie@cdevil.unx.sas.com
  6. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  7. Message-ID: <C0DyoI.5z6@unx.sas.com>
  8. Date: Tue, 5 Jan 1993 14:53:06 GMT
  9. References: <C02JCH.pC@ccu.umanitoba.ca> <marc.01d7@aargh.adsp.sub.org> <1993Jan4.203607.5246@bilver.uucp>
  10. Nntp-Posting-Host: cdevil.unx.sas.com
  11. Organization: SAS Institute Inc.
  12. Lines: 36
  13.  
  14.  
  15. In article <1993Jan4.203607.5246@bilver.uucp>, alex@bilver.uucp (Alex Matulich) writes:
  16. >marc@aargh.adsp.sub.org (Marc Heuler) writes:
  17. >>umbadiu0@ccu.umanitoba.ca (Ted Babiuk) writes:
  18. >>>is there something simular to a sleep() command which puts a task to sleep
  19. >>>for 'x' ticks? (and uses little/no cpu time?)
  20. >>
  21. >>There is, it's Delay() of dos.library.
  22. >
  23. >I have a similar but more complex question:
  24. >
  25. >Is there something similar to Delay() that will put the program to sleep
  26. >for a specified period of time but ALSO be interrupted by a keystroke?
  27. >I'm using the timer device to do this in an application that must wait for
  28. >clock events (the program is a video subtitler for foreign films), and it
  29. >would be nice for the program to be able to hear keystrokes *before* the
  30. >sleep time has elapsed.
  31. >
  32. >I can do it with a busy loop, constantly checking the system time and the
  33.                     ^^^^^^^^^  ARRGGGHHHH!
  34. >keyboard, but I'd like to avoid this.
  35.  
  36. How about just WaitForChar() in dos.library?  It waits for a keypress for a
  37. specified time, returning immediately if a key *is* actually pressed.
  38.  
  39. Otherwise, simply fire off a message to timer.device, and another to
  40. console.device, the Wait() on both signals.  Be sure to AbortIO() the one
  41. that didn't come back, or it could show up later, though.
  42.  
  43. -- 
  44. ---------------
  45. Jim Cooper
  46. (jamie@unx.sas.com)                             bix: jcooper
  47.  
  48. Any opinions expressed herein are mine (Mine, all mine!  Ha, ha, ha!),
  49. and not necessarily those of my employer.
  50.