comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Types Converting
Date: 1996/04/27
Date: 1996-04-27T00:00:00+00:00	[thread overview]
Message-ID: <DqJAHw.A35@world.std.com> (raw)
In-Reply-To: 4ltn0h$c37@rigel.rz.uni-ulm.de


In article <4ltn0h$c37@rigel.rz.uni-ulm.de>,
Joerg Rodemann <rodemann@mathematik.uni-ulm.de> wrote:
>   Message : String;

It's illegal to declare a variable of type String, unless you either
initialize it, or give bounds.  E.g. "Message: String := ...;" or
"Message: String(1..50);".

>   Message := "The Total is " & i'Image & " out of 100";

Image is an attribute of types, not variables.  E.g. "Integer'Image(I)".

What you want is something like:

    Message: constant String := "The total is" & Integer'Image(I) 
				& " out of 100";

Note that the 'Image attribute evilly adds an extra space (if I is
positive), so I didn't put a space after "is".

In my own code, I write an Image function, which avoids the annoying
extra space, and has lots of options like allowing hexadecimal, and
putting in underscores every 3 characters, etc.  All with defaults, of
course, so "Image(I)" does something reasonable.

- Bob




      reply	other threads:[~1996-04-27  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-27  0:00 Types Converting HSR Al-Dhaheri
1996-04-27  0:00 ` Joerg Rodemann
1996-04-27  0:00   ` Robert A Duff [this message]
replies disabled

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