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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e07818d50a32cdd7,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-03 15:30:06 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.mi.home.com.POSTED!not-for-mail From: "McDoobie" Subject: Constraint error? Newsgroups: comp.lang.ada Organization: Caffinated Corps User-Agent: Pan/0.8.1beta4 (Unix) X-No-Productlinks: Yes Message-ID: Date: Sun, 03 Jun 2001 22:30:05 GMT NNTP-Posting-Host: 24.0.109.49 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.mi.home.com 991607405 24.0.109.49 (Sun, 03 Jun 2001 15:30:05 PDT) NNTP-Posting-Date: Sun, 03 Jun 2001 15:30:05 PDT Xref: archiver1.google.com comp.lang.ada:8045 Date: 2001-06-03T22:30:05+00:00 List-Id: Alright, so I wrote a simple as hell Ada program that figures out the volume of an object. And it worked! I danced around, got all happy, and all the peasants rejoiced. Or so I thought. The program works with some values, but then raises a constraint error with others. Because it's so small, I'll post it up here. with Ada.Text_IO, Ada.Float_Text_IO; use Ada.Text_IO, Ada.Float_Text_IO; procedure simplevolume is Height : Float; Width : Float; Length : Float; -- The Variables for finding the volume of a shape. TotalVolume : Float; -- The variable that will hold the results. s : string(1..5); -- This variable contains 5 chars. Duh! len : natural; begin Put_Line( "Enter the Length here: "); Get_Line( s, len ); Length := float'value( s ); New_Line; Put_Line( "Enter the Width here: "); Get_Line( s, len ); Width := float'value( s ); New_Line; Put_Line( "Enter the Height here: "); Get_Line( s, len ); Height := float'value( s ); New_Line; -- It should be obvious what's occurring here. Were collecting the -- variables of the shape. TotalVolume := ((Length * Width) * Height); Put_Line( "The total Volume of the shape is: " & TotalVolume'img ); New_Line; Put_Line( "Goodbye!" ); end simplevolume; No fancy loops or anything of that nature. Just a straight drop though the code program. Now if I enter like 12.3 for the Length, it works fine, but if I enter like 5.0, I get a constraint error. The specific error I get is... raised CONSTRAIN_ERROR : s-valuti.adb:236 Now, could someone explain what I'm doing wrong here? I'm a little fuzzy on constraint errors. Thanks. McDoobie chris@dont.spam.me P.S. Try not to laugh. I'm still a greenhorn okay. ;->