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,WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.N5M2DXr2fJIsm61cKlUWUQ.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: gnat.string_split , howto manipulate slice numbers Date: Tue, 29 Oct 2019 08:35:29 +0000 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: N5M2DXr2fJIsm61cKlUWUQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:/txx9iM0Tas2TBcMzDiU9/gv0xo= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57361 Date: 2019-10-29T08:35:29+00:00 List-Id: 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);