From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Text_io package's Positive_Count type Date: Wed, 11 Jan 2023 23:42:17 +0200 Organization: Tidorum Ltd Message-ID: References: <1ef161c8-8e65-4a82-8db8-c772e813be80n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net L2VLQGkAv720F1xydhxFww8c9IN5yTlFR7zqqc/9XfhaGW+Mki Cancel-Lock: sha1:amXYy8exPcO43EC1VyQ/HyMePwk= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64798 List-Id: On 2023-01-11 23:04, Mace Ayres wrote: > -- combinations.ads -- physical file > with gearbox; use gearbox; > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > with Term_IO; use TERM_IO; > with Text_IO; use Text_IO; > package combinations is > ... > col_is : Positive_Count ; -- types from Text_IO > row_is : Positive_Count ; > procedure build; > ... > end combinations; > -- ************************************* > -- combinations.adb -- physical file > package body combination is > .... > procedure build is > .. > begin > ... > put(" Row is " ); put(row_is); > put(" Column is "); put(col_is); > ... > end combinations; > > -- ***************************** > compiler error > line_no : no candidate interpretations match the actual: > missing argument for parameter 'Item' in call to "put" > ... > possible missing instantiation of Text_IO.Integer_IO > expected type "Standard Integer" > found type Ada.Text_IO.count Thanks for showing the code (although it seems you have changed it since you asked the question originally). > ____ > This is different error than before and I easily see Put() is > expecting Integer but has the.. count type; so I need some sort of > translation to satisfy put(), maybe with and use Text_IO.Integer_IO > as error message suggest? Well, yes. But note that the message says you should _instantiate_ Text_IO.Integer_IO, not "with" it. This is because Text_IO.Integer_IO is not its own library unit, but a generic package nested within Text_IO, which you already "withed". So the message suggests that you should do this, somewhere in the declaration part of the body of package combination: package Count_IO is new Text_IO.Integer_IO (Num => Positive_Count); and then you can call Count_IO.Put (row_is); and so forth. Or, if you add "use Count_IO" after the instantiation, you can write just Put (row_is). However, the simplest method for occasional or debugging output is to use the 'Image attribute to convert a number to text, as for example Put (row_is'Image); or (for older Ada versions) Put (Positive_Count'Image (row_is)); where the "Put" is the Put in Text_IO for strings. With 'Image, you don't need Text_IO.Integer_IO (but you have less control over the form of the output).