comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Iswara <haujekchifan@gmail.com>
Subject: Get_Line skip input
Date: Thu, 26 Aug 2021 12:36:18 +0700	[thread overview]
Message-ID: <sg798l$3r0$1@gioia.aioe.org> (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?

             reply	other threads:[~2021-08-26  5:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26  5:36 Richard Iswara [this message]
2021-08-26  7:56 ` Get_Line skip input Niklas Holsti
2021-08-26  9:09 ` Jeffrey R. Carter
2021-08-27  2:55   ` Richard Iswara
replies disabled

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