comp.lang.ada
 help / color / mirror / Atom feed
* is there a put and wait
@ 1997-11-30  0:00 Robert A. Thompson
  0 siblings, 0 replies; only message in thread
From: Robert A. Thompson @ 1997-11-30  0:00 UTC (permalink / 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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-11-30  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-30  0:00 is there a put and wait Robert A. Thompson

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