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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,81d03ebf4bb55189 X-Google-Attributes: gid103376,public From: Greg Bond Subject: Re: How to convert an integer to a string?? Date: 1996/04/04 Message-ID: <3164497A.46EF@ee.ubc.ca>#1/1 X-Deja-AN: 145856613 references: <3163D6E3.645F@awadi.com.au> to: Tony Macrellis content-type: text/plain; charset=us-ascii organization: Dept. of Electrical Eng., UBC mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (Macintosh; I; PPC) Date: 1996-04-04T00:00:00+00:00 List-Id: Tony Macrellis wrote: > > I'm a newbie to ada and need some help! How do I convert an > integer to a string? Good question in light of the inadequate coverage of I/O issues in the Barnes Ada 95 text (pet peeve!). I discovered the following short-cut in the Ada95 for C/C++ on-line guide at http://lglwww.epfl.ch:80/Ada/Ammo/Cplpl2Ada.html "A simple program below uses Text_IO to print a message to the screen, including numerics! These are achieved by using the types attribute 'Image which gives back a String representation of a value. with Ada.Text_IO; use Ada.Text_IO; procedure Test_IO is begin Put_Line("Test Starts Here >"); Put_Line("Integer is " & Integer'Image(2)); Put_Line("Float is " & Float'Image(2.0)); Put_Line("Test Ends Here"); end Test_IO; It is also possible to use one of the generic child packages of Ada. Text_IO such as Ada.Text_IO.Integer_IO which can be instantiated with a particular type to provide type safe textual IO. with Ada.Text_IO; type My_Integer is new Integer; package My_Integer_IO is new Ada.Text_IO.Integer_IO(My_Integer); use My_Integer_IO; -- * Greg Bond * Dept. of Electrical Eng. * email: bond@ee.ubc.ca * Univ. of British Columbia * voice: (604) 822 0899 * 2356 Main Mall * fax: (604) 822 5949 * Vancouver, BC * web: http://www.ee.ubc.ca/~bond * Canada, V6T 1Z4