From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8dd8ee71ca4e5206 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-04 11:34:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.stealth.net!news.stealth.net!news-out.nuthinbutnews.com!propagator2-sterling!news-in-sterling.newsfeed.com!news-in.nuthinbutnews.com!cyclone1.gnilink.net!wn11feed!wn7feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Newbie question on Ada TExt_IO References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1033756487 12.234.13.56 (Fri, 04 Oct 2002 18:34:47 GMT) NNTP-Posting-Date: Fri, 04 Oct 2002 18:34:47 GMT Organization: AT&T Broadband Date: Fri, 04 Oct 2002 18:34:47 GMT Xref: archiver1.google.com comp.lang.ada:29523 Date: 2002-10-04T18:34:47+00:00 List-Id: > "last" is the size of the string, This is true only if Input'first is 1. ie, if you had Input : String(15 .. 237); and the user entered 2 characters, Last = 16 and Input(15 .. 16), or Input(Input'first .. Last), contains the two characters. It's not a good habit to assume the first subscript is 1 and Last is the length. Often a String has been passed to you as a parameter to a procedure, and the caller may have passed just a portion of some bigger string, say Input : String(1 .. 1024); ... Input(1 .. 14) := "abcdefghijklmn"; Some_Procedure(Input(15 .. 237)); Some_Procedure will fail if it assumes its input parameter'first = 1. >How do you evaluate the length of the string using "Input'Last" isn't always >going to be 256, it was for me? Input'last is the last legal subscript in Input. Given Input : String(1 .. 256); Input'last = 256. Permanently. Regardless of the content of Input. Last is a variable set by Get_Line that tells the last subscript Get_Line used to store an input character. If the user entered no characters then Get_Line sets Last = Input'first-1 (zero in your example). If he entered four characters "5432", then hit the Enter key, then the '2' goes into Input(4) and Last = 4.