comp.lang.ada
 help / color / mirror / Atom feed
* How do I "Get" just 4 characters?
@ 1993-03-04 19:22 Kenneth Anderson
  1993-03-04 22:18 ` Dat Trieu Le
  1993-03-05  5:56 ` Craig Manahan
  0 siblings, 2 replies; 6+ messages in thread
From: Kenneth Anderson @ 1993-03-04 19:22 UTC (permalink / raw)


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,

Ken



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1993-03-05 15:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-03-04 19:22 How do I "Get" just 4 characters? Kenneth Anderson
1993-03-04 22:18 ` Dat Trieu Le
1993-03-04 23:20   ` Ron Sercely
1993-03-05  5:45     ` Dat Trieu Le
1993-03-05 15:55       ` Ron Sercely
1993-03-05  5:56 ` Craig Manahan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox