comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert A. Thompson" <stdrat01@unx1.shsu.edu>
Subject: is there a put and wait
Date: 1997/11/30
Date: 1997-11-30T00:00:00+00:00	[thread overview]
Message-ID: <348139C0.30EBF63E@unx1.shsu.edu> (raw)


I am working on a homework assignment and am having problems with puting
to the screen a statement and then waiting for a resonpse.  I am sure it
is the multitasking of ada 95  (gnat 3.09 on a windows NT 4.0 system),
but it never waits for me to enter the data initially if teh put_line
and get are followed by another put?  I have tired put, and a package we
wrote back in my ada 101 class.

PROCEDURE GetName(PName : out string; len: out integer) is
begin
  put_string("Enter a the Name to insert");
  get_string(PName,len);

end;
-----------------------------------------------
PROCEDURE GetNumber(Number : out string; len: out integer) is

begin
  put_string("Enter the corresponding phone number");
  get_string(Number,len);new_line;
end;
-----------------------------------------------
PROCEDURE InsertProc is
 PName: string(1..12):=(others => ' ');
 Number: string(1..10):=(others => ' ');
 len: integer:=1;
begin
 new_line(40);
 put_string(" ");                                --- this is to try and
cause it to go ahead and skip
 get_string(pname,len);                     --- then show what I want
... this is ugly to do it
 len := 1;                                          ---  this way
 while (len /= 0) or (len /= 0) loop
  GetName(PName,len);
  GetNumber(Number,len);
 end loop;


No matter what I do it won't wait.  I have used all sorts of put and
even the package we wrote...which I show below

with text_io;
package body jc_strings is
        procedure get_string(a: out string; n: out integer) is

           i: integer;

           b: string(1..80);

           spc: string(1..a'last):= (others => ' ');

        begin --get_string
                text_io.get_line(b,i);

                if  i< a'last then
                    --string inputted has length less than target string

                    --pad with spaces
                    a(1..i):=b(1..i);
                    a(i+1..a'last):=spc(i+1..a'last);
                    n:=i;
                else
                    --string inputted has length >= target,
                    --truncate to target string
                    a(1..a'last):=b(1..a'last);
                    n:= a'last;
                end if;
        end get_string;

        procedure put_string(a: in string) is

           loc: integer:= a'last;

        begin --put_string
                while loc /=0 loop
                        if a(loc) = ' ' then
                                loc:= loc -1;
                         else
                                exit;
                         end if;
                end loop;
                if loc > 0 then
                        text_io.put(a(1..loc));
                end if;

        end put_string;
end jc_strings;



any help would be appreciated.

Robert A. Thompson





                 reply	other threads:[~1997-11-30  0:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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