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,e231a54b81077fa0 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: type conversion question Date: 2000/08/16 Message-ID: <8WEm5.2477$2l4.33427@newsread2.prod.itd.earthlink.net>#1/1 X-Deja-AN: 659120973 References: <399AF3F8.A5596932@tridsys.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 966466308 155.219.30.133 (Wed, 16 Aug 2000 15:51:48 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net X-MSMail-Priority: Normal NNTP-Posting-Date: Wed, 16 Aug 2000 15:51:48 PDT Newsgroups: comp.lang.ada Date: 2000-08-16T00:00:00+00:00 List-Id: To obtain a string from a scalar type, you need to use 'Image, which is just the opposite of 'Value. "Raju Vemulamanda" wrote in message news:399AF3F8.A5596932@tridsys.com... > Hi, > Could someone please clarify my doubt on the type conversion? > Somebody has answered my previous question through > comp.lang.ada@ada.eu.org. > Below is the question and the answer I got.. > Now I am using the same way to do exactly opposite. > I have an integer of type Integer_32 which is predefined in our code. > I want to convert it into a string.... like > > type Integer_32 is new Base_Integer range -2 ** 31 .. 2 ** 31 - 1; > new_fieldvalue : Integer_32; > > what I am attempting to do is.... > > Text_Io.Put_Line(Vmf_File2, String'Value(new_fieldvalue)); > > The error I am getting is ... > pretext of "Value" attribute must be scalar type > > whats wrong in it??? > > Can someone please answer this.. > > raju > > my previous question > > > 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. > > answer: > > Here's a complete example: > > with Ada.Text_Io; > procedure Size_Demo is > > package Text_Io renames Ada.Text_Io; > > type Bit_5 is range 2#0# .. 2#11111#; > for Bit_5'Size use 5; > subtype Size_Type is Bit_5; > > val1 : Size_Type; > input_string : String(1..10); > last_char : Natural; > > begin > Text_Io.Put( "Enter Value => " ); > Text_Io.Get_Line( input_string, last_char ); > val1 := Size_Type'Value( input_string( 1 .. last_char ) ); > > Text_Io.Put_Line( "Value is: " & Size_Type'Image( val1 ) ); > end Size_Demo; > > > >