comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Type casting question
Date: 1999/12/21
Date: 1999-12-21T14:54:54+00:00	[thread overview]
Message-ID: <83o4bu$iot$1@hobbes2.crc.com> (raw)
In-Reply-To: 385E87D8.2B44B800@tridsys.com


Raju Vemulamanda <raju@tridsys.com> wrote in message
news:385E87D8.2B44B800@tridsys.com...
> Question: Could someone please provide some solution
>   to the below?
>
> I have this question in the conversion of values
> between the string and the my own type shown below.
>
> type Bit_5 is range 2#0# .. 2#11111#;
>     for Bit_5'Size use 5;
> subtype Size_Type is Bit_5;
>
> The above is how Size_Type has been declared.
>
> val1 : Jvmfr3_Field_Types.Size_Type := 10;
>
> Suppose I have a string xxx which has the some value in it,
> How can I convert that xxx into the above declared val1?
> I have to copy xxx into val1. I need to somehow do the
> type casting for the above.
Any valid string representation of a scalar value can be converted
to the corresponding value by using the 'Value attribute of the
type.  So.... for your type Bit_5, if you have the declaration:

A_Bit_5_Value : Bit_5;


Then you can say A_Bit_5_Value := Bit_5'Value ("2#10101#");








      parent reply	other threads:[~1999-12-21  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-20  0:00 Type casting question Raju Vemulamanda
1999-12-20  0:00 ` DuckE
1999-12-21  0:00 ` Robert Dewar
1999-12-21  0:00 ` Robert Dewar
1999-12-21  0:00   ` reason67
1999-12-21  0:00     ` Robert Dewar
1999-12-21  0:00       ` reason67
1999-12-22  0:00         ` Ted Dennison
1999-12-23  0:00         ` Robert Dewar
1999-12-23  0:00           ` reason67
1999-12-23  0:00             ` Larry Kilgallen
1999-12-24  0:00               ` Robert Dewar
1999-12-23  0:00             ` reason67
1999-12-23  0:00             ` Robert Dewar
1999-12-23  0:00             ` Robert Dewar
1999-12-21  0:00 ` David C. Hoos, Sr. [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