comp.lang.ada
 help / color / mirror / Atom feed
* Get_Line skip input
@ 2021-08-26  5:36 Richard Iswara
  2021-08-26  7:56 ` Niklas Holsti
  2021-08-26  9:09 ` Jeffrey R. Carter
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Iswara @ 2021-08-26  5:36 UTC (permalink / raw)


Why do Get_Line skipped the input? I have the following code:

    -- late declaration of Key words string array
    declare
       type Kw_Array is array (1 .. Kw_Numbers) of String (1 .. 10);
       Key_Words : Kw_Array;
       type W_Len_Array is array (1 .. Kw_Numbers) of Natural;
       W_Len, Multiplier : W_Len_Array;

    begin
       Ada.Text_IO.Put_Line ("Enter keywords less than 10 characters.");
       for i in 1 .. Kw_Numbers loop
          Ada.Text_IO.Put ("Keywords number ");
          Ada.Integer_Text_IO.Put (i, 1);
          Ada.Text_IO.Put (" = ");
+         Ada.Text_IO.Get_Line (Key_Words (i), W_Len (i));
 >         Ada.Text_IO.Put("Enter multiplier for keyword ");
 >         Ada.Integer_Text_IO.Get(Multiplier(i),1);
          Ada.Text_IO.New_Line;
       end loop;
    end;

Before I put the two lines marked above, the executable only skipped the 
first instance of keyword entry.
After I put those two lines, the executable completely skipped the 
Get_Line part.
So on the terminal it shows like this:
Keywords number 1 =  Enter Multiplier for keyword <here cursor wait for 
entry>
Keywords number 2 =  Enter Multiplier for keyword <here cursor wait for 
entry>

If I modifies the line marked + into Get (Key_Words (i) (1..W_Len(i))) 
the compiler complain I did not assign W_Len. Most likely I get the 
syntax incorrect.

What do I do wrong on the original code?

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

end of thread, other threads:[~2021-08-27  2:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26  5:36 Get_Line skip input Richard Iswara
2021-08-26  7:56 ` Niklas Holsti
2021-08-26  9:09 ` Jeffrey R. Carter
2021-08-27  2:55   ` Richard Iswara

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