comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Input a string (again)
Date: Sat, 29 Jan 2005 15:03:23 -0600
Date: 2005-01-29T15:03:23-06:00	[thread overview]
Message-ID: <2dWdnbwA872GZ2bcRVn-gw@comcast.com> (raw)
In-Reply-To: 36119gF4r0h1aU2@individual.net

> After I'm now able to input a string (30 chars),
> ...
>         Get_Line(sString, iString_Length);
> ...
>         return sString;
  "Get_Line" really ought to be renamed "Read_Into_Buffer" or something.
Don't think of sString as your input string, think of it as a buffer
that will hold up to 30 characters of input.  The actual string typed
in by the user is in the first iString_Length positions in the buffer,
so sString(1 .. iString_Length) is the typed input.
  BTW, in Ada strings don't necessarily have to start with an index
of 1.  For instance, a procedure might be called with a string parameter
which is position 5 .. 10 of some larger string.  So it's safer to be
in the habit of not assuming a start index of 1.  Thus you should have:
          Get_Line(sString, iString_Last);
and
          return sString(sString'first .. iString_Last);



      parent reply	other threads:[~2005-01-29 21:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-29  8:55 Input a string (again) Stefan Merwitz
2005-01-29  9:53 ` Adrian Knoth
2005-01-29 12:51 ` Stefan Merwitz
2005-01-29 21:03 ` tmoran [this message]
replies disabled

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