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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5f17fa7cb3683a60 X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: File Problem. Please help.. Date: 1996/08/01 Message-ID: <4tqdtv$2kb@newsbf02.news.aol.com>#1/1 X-Deja-AN: 171659813 sender: root@newsbf02.news.aol.com references: <4tp9re$r7a@news.us.net> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-08-01T00:00:00+00:00 List-Id: mhall59@mail.us.net (Michael W. Hall) writes: > I have figured out that I got an error because > my values were higher than 32767(or whatever > is the largest int value) How can I use a 16 bit > or 32 bit number? Is there a way to set this? First, it looks like you're using an Ada 83 compiler, so I'll answer in terms of Ada 83. The "cheap and dirty" way to fix the problem of integer values higher than 32767 is to see if your compiler provides a type Long_Integer, and use that instead of Integer. However, I don't recommend that, because Ada provides a much more portable solution! Looking at your data file, I see that your integers range up to 104570. Let's be conservative and say that your integers can range up to a half million. In Ada you can define a user-defined type: type My_Int is range 0 .. 500_000; Now, use My_Int instead of Integer (or Long_Integer). You'll have to instantiate Integer_IO for the type My_Int. With the declaration above, each Ada compiler will automatically select the appropriate integer type. A compiler that implements type Integer with 32 bits will select Integer, while a compiler that implements type Integer with 16 bits will select Long_Integer if it's available. All automatically, so your code is perfectly portable! > Also how can I read the strings into a single > variable while looping if they are different lengths? I like to use Get_Line for strings instead of Get. You need to declare not only the String variable (Name), but its length as an Integer (e.g., Name_Len : Integer;). Then do Text_IO.Get_Line(File => Data_File, Item => Name, Last => Name_Len); Name_Len will contain the number of characters in the line you read in, and the first Name_Len characters of Name will be stored into (the rest of Name will be unchanged). If you don't want your Get_Data to store into a global variable, add an extra out parameter for the length, and store into that parameter and Plant_Name. I hope this helps. For more about user-defined types and portability, download the Ada Tutor program at the Web or FTP site below my signature. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor