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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7956d7dcc9685cb5 X-Google-Attributes: gid103376,public From: reason67@my-deja.com Subject: Re: Help ... CONSTRAINT_ERROR Date: 1999/11/30 Message-ID: <820qf9$ic3$1@nnrp1.deja.com>#1/1 X-Deja-AN: 554832974 References: <81vfu6$sem$1@tobruk.sydney.gecm.com> X-Http-Proxy: NetCache@www-blv-proxy2.boeing.com: Version NetApp Release 3.4D6: Mon Aug 23 16:40:19 PDT 1999-Solaris, 1.0 x35.deja.com:80 (Squid/1.1.22) for client 12.13.226.12 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Nov 30 15:28:47 1999 GMT X-MyDeja-Info: XMYDJUIDreason67 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.05 [en]C-Boeing Kit (Win95; I) Date: 1999-11-30T00:00:00+00:00 List-Id: In article <81vfu6$sem$1@tobruk.sydney.gecm.com>, "jxredi" wrote: > > Hi, > I was wondering if you could help me out with this problem (using ADA83) : > > package R_IO is new TEXT_IO.FLOAT_IO(Float); > NUM : STRING := "hi there"; > FNUM : Float := 0.75; > R_IO.PUT(NUM,FNUM); -- this is where the problem is ... but what's wrong > ?? > > ------------ > RUN-TIME ERROR : "constraint_error". The code you posted would not compile: NUM : STRING := "hi there"; The string length of a variable has to be defined. If this was a constant, it would work as it would get the length from the string, but as a variable, you would have to say (1 .. 8) after the String. Assuming a typo and it is (1 .. 8), I know the problem: R_IO.PUT (NUM, FNUM); Is this call: procedure Put(To : out String; Item : in Num; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); Num is 8 characters long and if you are using float, most likely that is a single precisions IEEE floating point (have to know your compiler to be certain as it is implementation defined) and without specifying the aft or exponent it will try to write a 6 digit string with 1 decimal and 3 characters for exponent and 1 character for sign in the form "sd.dddddEnn" which is longer than 8 characters. That is causing your constaint error. Change Num to String (1 .. 20) and it should work. Once it does see how many digits are displayed (probably 6) and how long the exponent is and add 4 characters and that is the minimum size string you should use. Hope this helps. --- Jeffrey Blatt Sent via Deja.com http://www.deja.com/ Before you buy.