comp.lang.ada
 help / color / mirror / Atom feed
* Integer to String Conversion?
@ 1998-12-16  0:00 bwefler
  1998-12-16  0:00 ` dennison
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: bwefler @ 1998-12-16  0:00 UTC (permalink / raw)


Does anyone know an Ada-83 compatible method to convert an integer to a
string, so that the string may be concatenated with another string, and the
resulting string passed as a parameter to a function call?  (Note: I am not
talking about using Text_IO or Integer_IO in this case;  I simply want the
result to be a string.	Another function will take care of the string.)

Thanks.
--
bw

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Integer to String Conversion?
  1998-12-16  0:00 Integer to String Conversion? bwefler
  1998-12-16  0:00 ` dennison
  1998-12-16  0:00 ` Matthew Heaney
@ 1998-12-16  0:00 ` Tom Moran
  1998-12-16  0:00 ` Marin David Condic
  3 siblings, 0 replies; 6+ messages in thread
From: Tom Moran @ 1998-12-16  0:00 UTC (permalink / raw)


>Does anyone know an Ada-83 compatible method to convert an integer to a
>string, so that the string may be concatenated with another string, and...
Send_Message("Count has reached" & Integer'Image(Count));
for example?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Integer to String Conversion?
  1998-12-16  0:00 Integer to String Conversion? bwefler
  1998-12-16  0:00 ` dennison
@ 1998-12-16  0:00 ` Matthew Heaney
  1998-12-18  0:00   ` dewarr
  1998-12-16  0:00 ` Tom Moran
  1998-12-16  0:00 ` Marin David Condic
  3 siblings, 1 reply; 6+ messages in thread
From: Matthew Heaney @ 1998-12-16  0:00 UTC (permalink / raw)


bwefler@my-dejanews.com writes:

> Does anyone know an Ada-83 compatible method to convert an integer to a
> string, so that the string may be concatenated with another string, and the
> resulting string passed as a parameter to a function call?  (Note: I am not
> talking about using Text_IO or Integer_IO in this case;  I simply want the
> result to be a string.	Another function will take care of the string.)

This has to be the number one FAQ these days:

  X : Integer;
...
  Put ("this is a string" & Integer'Image (X));

Integer'Value goes the other way, and converts a string into an
integer.  It'll even convert alternate bases, ie

  Integer'Value ("16#A#")  returns the value 10 (decimal)





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Integer to String Conversion?
  1998-12-16  0:00 Integer to String Conversion? bwefler
@ 1998-12-16  0:00 ` dennison
  1998-12-16  0:00 ` Matthew Heaney
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: dennison @ 1998-12-16  0:00 UTC (permalink / raw)


In article <756ue7$7o3$1@nnrp1.dejanews.com>,
  bwefler@my-dejanews.com wrote:
> Does anyone know an Ada-83 compatible method to convert an integer to a
> string, so that the string may be concatenated with another string, and the
> resulting string passed as a parameter to a function call?  (Note: I am not
> talking about using Text_IO or Integer_IO in this case;  I simply want the
> result to be a string.	Another function will take care of the string.)

It sounds like you want the "'image" attribute.

I highly suggest you go through Annex A of your Ada 83 LRM (available online
at http://www.adahome.com/LRM/83/RM/rm83html/ ) and read about *all* the
attributes. There are all sorts of goodies in there to make your life easier.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Integer to String Conversion?
  1998-12-16  0:00 Integer to String Conversion? bwefler
                   ` (2 preceding siblings ...)
  1998-12-16  0:00 ` Tom Moran
@ 1998-12-16  0:00 ` Marin David Condic
  3 siblings, 0 replies; 6+ messages in thread
From: Marin David Condic @ 1998-12-16  0:00 UTC (permalink / raw)


bwefler@my-dejanews.com wrote:
> 
> Does anyone know an Ada-83 compatible method to convert an integer to a
> string, so that the string may be concatenated with another string, and the
> resulting string passed as a parameter to a function call?  (Note: I am not
> talking about using Text_IO or Integer_IO in this case;  I simply want the
> result to be a string.  Another function will take care of the string.)
> 
The usual way is with the 'Image attribute, but you may need to exercise
a little caution, given that it is defined to return either a leading
minus sign or a leading space and in either case, whatever you pass it
to has to deal with that appropriately.

See the Ada83 LRM, 3.5.5(10)

For the type "Integer" and an object "X" of type "Integer" you would
have a function like this:

Integer'Image (X)

This will return the character string.

There is also, within Text_IO.Integer_IO a procedure "Put" which can put
an integer into a string, rather than to a file. This is typically more
work than the 'Image solution.

MDC
-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
Ph: 561.796.8997         Fx: 561.796.4669
***To reply, remove "bogon" from the domain name.***

"Eagles may soar, but a weasle never gets sucked up into a jet engine."

        --  Author Unknown




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Integer to String Conversion?
  1998-12-16  0:00 ` Matthew Heaney
@ 1998-12-18  0:00   ` dewarr
  0 siblings, 0 replies; 6+ messages in thread
From: dewarr @ 1998-12-18  0:00 UTC (permalink / raw)


In article <m3k8zsbstf.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:
> This has to be the number one FAQ these days:


Not only is this question frequently asked, but every time
it is asked, we get dozens of replies (often from people
who are obviously NOT following threads before answering).
Perhaps we should take it in turns to be the official
'Image answerer for the month.

Seriously, it would really help if people would thread
follow before posting answers to questions like this

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-12-18  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-16  0:00 Integer to String Conversion? bwefler
1998-12-16  0:00 ` dennison
1998-12-16  0:00 ` Matthew Heaney
1998-12-18  0:00   ` dewarr
1998-12-16  0:00 ` Tom Moran
1998-12-16  0:00 ` Marin David Condic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox