From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 3 Feb 93 14:14:53 GMT From: agate!spool.mu.edu!howland.reston.ans.net!bogus.sura.net!darwin.sura.net! seas.gwu.edu!mfeldman@ucbvax.Berkeley.EDU (Michael Feldman) Subject: Re: simple help with Text_IO Message-ID: <1993Feb3.141453.28853@seas.gwu.edu> List-Id: In article ccalbrec@laplace.uwaterloo. ca (Cory C. Albrecht) writes: [stuff deleted] >With Text_IO; Use Text_IO; > >Procedure main is > >instr, tokstr : String(1..255); ^^^^^^^^^^^^^^---------- a 255-character string > >Begin >Loop > New_Line; > Put("*>> "); > Get(instr); -- this is where it stalls and won't go furthe r ^^^^^^^^^^^------------------------- which you are trying to read here > New_Line; > Put("*:: "); > Put(instr); > Exit When instr="quit"; >End Loop; >End; --main > > > Sigh...Ada strings are nothing magic, just arrays of characters. Text_IO.Get(...string...) will attempt to read _exactly_ the number of characters specified (and it skips over CRs!). Your Get will not be satisfied until it gets exactly 255 characters. There's nothing "hung" about your program; it's simply waiting for the rest of the input. This is an extremely common misunderstanding about strings and Text_IO; my students bump into it all the time. To solve your problem, use Get_Line instead. Look it up in your text, or ask your teacher, or read the LRM section describing how the various Get's work. (Blatant plug: my freshman-level text explains it pretty well; so do most newer books.) Good luck - Mike Feldman ------------------------------------------------------------------------ Michael B. Feldman co-chair, SIGAda Education Committee Professor, Dept. of Electrical Engineering and Computer Science School of Engineering and Applied Science The George Washington University Washington, DC 20052 USA (202) 994-5253 (voice) (202) 994-5296 (fax) mfeldman@seas.gwu.edu (Internet) "Americans want the fruits of patience -- and they want them now." ------------------------------------------------------------------------