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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How do i print stuff? Date: Sat, 28 Oct 2017 21:30:56 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net vAuKf3nG+CIHP/F6MAKcFAtNcWjvpdJVcXkMgQaY/dfZysnawD Cancel-Lock: sha1:I4zFL+8cCj76+wSFOjhlP9PjCzI= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:48615 Date: 2017-10-28T21:30:56+03:00 List-Id: On 17-10-28 21:07 , tclwarrior@gmail.com wrote: > Hi, > > This is my first day learning Ada Heartily welcome! ... > if c then > Ada.Text_IO.Put_Line("true"); > else > Ada.Text_IO.Put_Line("false"); > End if; ... > But, I failed miserable to simply Print a, b and c > well, I kind of succeeded in printing a and b using > Float_Text_IO.Put What do you mean "kind of" ? Text_IO is the "print" in Ada. > But could not find a way to Print c (a boolean) Boolean is an enumeration type, so the canonical way would be to create an instance of the package Ada.Text_IO.Enumeration_IO for the Boolean type, and use that. The instance will provide both input and output. If all you need is to print a Boolean value, you can use the attribute function Boolean'Image to convert a Boolean value to a string. Here Boolean'Image (True) = "TRUE" Boolean'Image (False) = "FALSE" so you can do Ada.Text_IO.Put_Line (Boolean'Image (c)); and get TRUE or FALSE printed. > Well, so my question, that is the strategy to print stuff in Ada > does have have a print statement that can print any type No, there is no such print statement. > does each type have his one print statement In principle, yes; there are a set of generic packages that you can instantiate to provide I/O for your types. > How do I cast floats and booleans to strings? Most scalar types have a 'Image attribute. The inverse attribute is 'Value, which converts a string into a value. For example, Boolean'Value ("TRUE") = True. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .