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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,343551ac8a3d0216 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-04 14:18:37 PST Path: sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ehsn4.cen.uiuc.edu!dl10696 From: dl10696@ehsn4.cen.uiuc.edu (Dat Trieu Le) Newsgroups: comp.lang.ada Subject: Re: How do I "Get" just 4 characters? Message-ID: Date: 4 Mar 93 22:18:37 GMT Article-I.D.: news.C3Dxz1.J81 References: <9303041121.aa12530@Paris.ics.uci.edu> Sender: usenet@news.cso.uiuc.edu (Net Noise owner) Organization: University of Illinois at Urbana Date: 1993-03-04T22:18:37+00:00 List-Id: kanderso@mabillon.ICS.UCI.EDU (Kenneth Anderson) writes: >I had a question posed to me by one of my students, that asked : How >do I get just 4 characters of input? >Using the following program as an example: >with Text_IO; >procedure test is > subtype pin_type is string(1..4); > A : pin_type; > Num : INTEGER; >begin > Text_IO.Get(A); > Text_IO.PUT_LINE(A); >end test; >Now then, if I run the program and type "1234567890", >what I see is >1234567890 >1234 >What I would like to see is this: >1234 >1234 >I.E. I don't want to see 567890, I want the program to kick in right away >after the fourth character is typed, not wait for the user to type Return. >I tried changing the program to this: >with Text_IO; >procedure test is > subtype pin_type is string(1..4); > A : pin_type; > B : CHARACTER; >begin > Get(B); > A(1) := B; > Get(B); > A(2) := B; > Get(B); > A(3) := B; > Get(B); > A(4) := B; > Text_IO.PUT_LINE(A); >end test; >But the same behavior results... >Any suggestions? >Thanks in advance, Hi Ken, I believe TEXT_IO works much like buffered input io. That is, it will read from the input buffer. the Get message reads from that buffer. If there is not enough characters in the buffer, then the program will wait until the user has completed its input to the buffer. Text_IO doesn't consider inputs to be complete until it is followed by a carriage-return. If you want Ada to interpret characters one-at-a-time, then a routine to interface to the hardware may have to be written. hope this helps.