From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e759c9142eba3ec1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-19 14:57:36 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!elnk-pas-nf1!elnk-nf2-pas!newsfeed.earthlink.net!wn54feed!worldnet.att.net!attbi_s01.POSTED!not-for-mail Message-ID: <40354027.C7D28149@mchsi.com> From: Bruce or Tracy Jacobs Reply-To: bruce.tracy@the-jacobs.org X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Keyboard Polling Solution References: <4033DB01.2CE34E32@me.org> <4034A229.8080403@noplace.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 12.218.74.234 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s01 1077231455 12.218.74.234 (Thu, 19 Feb 2004 22:57:35 GMT) NNTP-Posting-Date: Thu, 19 Feb 2004 22:57:35 GMT Organization: MediaCom High Speed Internet Date: Thu, 19 Feb 2004 22:57:35 GMT Xref: archiver1.google.com comp.lang.ada:5677 Date: 2004-02-19T22:57:35+00:00 List-Id: A version of Get_Immediate does this. If there is nothing in the buffer, it returns FALSE and lets you continue on. Marin David Condic wrote: > > An observation would be that this is not truly "polling" in the sense > that Get_Immediate is going to block waiting for a keystroke. It does > get one keystroke at a time - which is often what you want, but Preben > is right about tasks. If you want to test for a keystroke being > available and otherwise go on about some other business, you should look > at building a task around Get_Immediate that would queue up keystrokes. > > MDC > > Preben Randhol wrote: > >> > >>with Text_IO; use Text_IO; > >> > >>procedure Test is > >> > >> My_Char : CHARACTER := ' '; > >> Character_Exists : BOOLEAN := FALSE; > >> Loop_Counter : INTEGER := 0; > >> > >>procedure Take_A_Break is begin put_line ("Taking a break from > >>polling..."); end Take_A_Break; > >> > >>begin > >> > >> loop > >> Loop_Counter := Loop_Counter + 1; > >> for X in 1..10000 loop > >> Get_Immediate (Item => My_Char, > >> Available => Character_Exists); > >> if (Character_Exists) then > >> put_line ("Character entered. Done."); > >> return; > >> end if; > >> end loop; > >> Take_A_Break; > >> end loop; > >> > >>end; > >> > >> > > > > > > Hmm, to me this looks like you want to read about tasks in Ada. > > > > -- > ====================================================================== > Marin David Condic > I work for: http://www.belcan.com/ > My project is: http://www.jsf.mil/NSFrames.htm > > Send Replies To: m o d c @ a m o g > c n i c . r > > "Face it ladies, its not the dress that makes you look fat. > Its the FAT that makes you look fat." > > -- Al Bundy > > ======================================================================