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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, LOTS_OF_MONEY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,36c55584044f4f0f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-08 06:02:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: string manipulation Date: Sun, 8 Dec 2002 09:02:34 -0500 Organization: MindSpring Enterprises Message-ID: References: NNTP-Posting-Host: d1.56.be.51 X-Server-Date: 8 Dec 2002 14:02:51 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: archiver1.google.com comp.lang.ada:31549 Date: 2002-12-08T14:02:51+00:00 List-Id: It is technically possible, but the question seems to imply a bit of confusion about the nature of the type String in Ada. String is a data type that is an array - nothing more or less. Its element type is Character. Hence, just as you can declare a type like: type Vector is array (Integer range <>) of Float ; and then make specific variables with specific numbers of elements: My_Vector : Vector (1..10) ; Your_Vector : Vector (20..50) ; The exact same thing is legal in Ada for the type String. It is important to understand that the 'Length doesn't have anything to do with the content of the string - just the number of positions in the array. The thing is that often programmers from other languages are used to strings taking on dynamic sizes depending on what is assigned to them In C, it is done - in a way - by including a null character somewhere in the array of characters to indicate termination. This can be done in Ada as well, but is highly unnatural and not recommended. If you are interested in strings with a more dynamic nature, look at Ada.Strings.Bounded and Ada.Strings.Unbounded in the ARM. (Also Ada.Strings.Fixed, if you want to deal with the standard String type.) Both Bounded and Unbounded strings give you better ability to look at the length of the string as a function of its content. MDC -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jast.mil/ Send Replies To: m c o n d i c @ a c m . o r g "I'd trade it all for just a little more" -- Charles Montgomery Burns, [4F10] ====================================================================== Gep wrote in message news:ynvI9.27498$Mn4.329910@wagner.videotron.net... > > "Gep" wrote in message > news:BhvI9.27495$Mn4.328936@wagner.videotron.net... > > Is it possible to declare a string to be exactly 10 characters long and > > still be a variable? then > > for example > > > > declare V_string as being exactly 10 characters > > > > > > while not valid > > loop > > get_line(V_string, V_length); > > > > if v_Art_lng = t_Art_article.t_art_proprietaire.v_nas'length then > > Skip_Line; > > Valid := True; > > else > > valid :=false; > > Put("invalid"); > > end if; > > > > end loop; > > > oops the code should be as follows > > while not valid > loop > get_line(V_string, V_length); > > if V_length= V_string'length then > Skip_Line; > Valid := True; > else > valid :=false; > Put("invalid"); > end if; > end loop; > > >