From: Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU>
Subject: Re: Please Help.
Date: 1997/09/09
Date: 1997-09-09T00:00:00+00:00 [thread overview]
Message-ID: <5v2qk5$cpu$1@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: 01bcbcde$f8a425c0$ca70fe8c@default
"with Text_IO;
use Text_IO;
Procedure GetName is
Name : String(1..12);
begin
Put("Please enter name : ");
Get(Name);
end GetName;
Simple answer:
with Text_IO; use Text_IO;
Procedure GetName is
Name : String(1..12);
Last : Natural;
begin
Put ("Please enter name : ");
Get_Line (Name, Last);
Put ("Hello ");
Put_Line (Name (1..Last));
end GetName;
Long answer:
If you want to deal with variable length data like this (esp
store it in a record) then use an appropriate type, rather than
string, e.g. Unbounded_String.
with Text_IO; use Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Unbounded_IO; use Unbounded_IO;
Procedure GetName is
Name : Unbounded_String;
begin
Put ("Please enter name : ");
Get_Line (Name);
Put ("Hello ");
Put_Line (Name);
end GetName;
(note that Unbounded_IO is a simple package that i wrote). In my
experience variable length string handling is one thing that has
turned students off Ada a lot. Unbounded_String is a godsend in
this respect. It's a pity that a standard I/O package wasn't
defined in the standard for this type.
Dale
next prev parent reply other threads:[~1997-09-09 0:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-09 0:00 Please Help Ken
1997-09-09 0:00 ` Stephen Leake
1997-09-09 0:00 ` Dale Stanbrough [this message]
1997-09-11 0:00 ` Robert Dewar
1997-09-12 0:00 ` Tristan Ludowyk
1997-09-12 0:00 ` Dale Stanbrough
1997-09-12 0:00 ` Stephen Leake
1997-09-13 0:00 ` Robert Dewar
1997-09-15 0:00 ` Stephen Leake
1997-09-15 0:00 ` Dale Stanbrough
1997-09-16 0:00 ` Robert Dewar
1997-09-17 0:00 ` Stephen Leake
1997-09-18 0:00 ` Robert Dewar
1997-09-19 0:00 ` Stephen Leake
1997-09-19 0:00 ` Robert S. White
1997-09-20 0:00 ` Robert Dewar
1997-09-12 0:00 ` Robert Dewar
1997-09-13 0:00 ` Matthew Heaney
1997-09-13 0:00 ` Dale Stanbrough
1997-09-15 0:00 ` Richard A. O'Keefe
1997-09-16 0:00 ` Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
2001-10-25 6:55 please help Phosphorus
2001-10-25 8:22 ` Preben Randhol
2001-10-25 12:35 ` Marc A. Criley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox