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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:344a:: with SMTP id v10mr1144736qtb.323.1572348045095; Tue, 29 Oct 2019 04:20:45 -0700 (PDT) X-Received: by 2002:aca:e002:: with SMTP id x2mr3400148oig.84.1572348044804; Tue, 29 Oct 2019 04:20:44 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!j16no184273qtl.0!news-out.google.com!d16ni340qtp.0!nntp.google.com!j16no184263qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Oct 2019 04:20:44 -0700 (PDT) In-Reply-To: <5d710dac-d172-4a31-899e-1bf95e220ed6@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:a03f:e3e9:4d00:1260:4bff:fe89:deb2; posting-account=kTRirAoAAACnF_wtAOSamxYBSVvmJuCa NNTP-Posting-Host: 2a02:a03f:e3e9:4d00:1260:4bff:fe89:deb2 References: <5d710dac-d172-4a31-899e-1bf95e220ed6@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7fb6d1d0-18df-43b9-bcdc-9782dfb5171c@googlegroups.com> Subject: Re: gnat.string_split , howto manipulate slice numbers From: Alain De Vos Injection-Date: Tue, 29 Oct 2019 11:20:45 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57366 Date: 2019-10-29T04:20:44-07:00 List-Id: On Tuesday, October 29, 2019 at 12:08:12 PM UTC+1, Alain De Vos wrote: > On Tuesday, October 29, 2019 at 9:35:31 AM UTC+1, Simon Wright wrote: > > Alain De Vos writes: > > > > > I have a String_Split.Slice_Number , but I need the number before. > > > ... > > > J := String_Split.Slice_Count (Lines); > > > for I in 2 .. J loop > > > ... > > > This works but , > > > ... > > > J := String_Split.Slice_Count (Lines) - 1 ; > > > for I in 2 .. J loop > > > ... > > > This does not work. > > > Error : > > > lsblk.adb:91:44: operator for type "Slice_Number" defined at > > > g-arrspl.ads:116, instance at g-strspl.ads:39 is not directly visible > > > > The error message says that there is an operator "-" for Slice_Number, > > but it needs to be made directly visible; either "use String_Split", or > > "use type String_Split.Slice_Count". > > > > However! clearly Lines is of some numeric type (Natural?) defined > > earlier, for which operator "-" is visible. So use that operator > > instead, by applying it before the conversion: > > > > J := String_Split.Slice_Count (Lines - 1); > > Lines is of type , > > Lines : String_Split.Slice_Set; ------------------------------------------------- I tested and the addition of , use type GNAT.String_Split.Slice_Number; fixed it. I looks like without it the operator - is not understood.