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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf9dfbced2c99710 X-Google-Attributes: gid103376,public From: Joel VanLaven Subject: Re: Buffering inputted characters Date: 1998/06/20 Message-ID: <358bf5a3.0@news4.his.com>#1/1 X-Deja-AN: 364518244 Sender: Joel VanLaven References: <898358420.19245.0.nnrp-08.c2de5e53@news.demon.co.uk> Organization: OC Systems Newsgroups: comp.lang.ada Date: 1998-06-20T00:00:00+00:00 List-Id: PantsMaster wrote: : I am attempting to write a game in Ada 95. I am aware that this is hardly : the most optimal platform for building a game, but nevertheless I am giving : it a go. What I would like to know is how I can get a program to look for : (keyboard) input. It would check to see if there has been any, and carry : out appropriate actions depending on the input. How can this be done : *without holding up the rest of the program?* Text_io.get_immediate is your answer. Note that this will also return control characters like new-lines and such (as opposed to get). Note that simce this is a new Ada95 feature that requires new ways of doing things some implementations might not get it completely right :) However, I think that new features like this have firmed up alot since the first Ada95 compilers. Here is A.10.7 (11-12) from the Ada95 LRM: procedure Get_Immediate(File : in File_Type; Item : out Character; Available : out Boolean); procedure Get_Immediate(Item : out Character; Available : out Boolean); f a character, either control or graphic, is available from the specified File or the default input file, then the character is read; Available is True and Item contains the value of this character. If a character is not available, then Available is False and the value of Item is not specified. Mode_Error is propagated if the mode of the file is not In_File. End_Error is propagated if at the end of the file. The current column, line and page numbers for the file are not affected. Note that there is a get_immediate without the available parameter. This will cause the program to await input in the same way the get procedure will. -- Joel VanLaven