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,ae9506fd4dcf7090 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-10 09:07:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!129.240.148.23!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Concatenation and Characters Date: Thu, 10 Oct 2002 16:07:09 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <12hp9.796$_u6.380@nwrddc01.gnilink.net> NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1034266029 282 129.241.83.78 (10 Oct 2002 16:07:09 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Thu, 10 Oct 2002 16:07:09 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:29676 Date: 2002-10-10T16:07:09+00:00 List-Id: Justin Birtwell wrote: > This is what I don't understand! How can you declare a string variable when > you don't know before hand what the string is going to be? Do you overload > the String like String(1..80) and hope for the best? This seems like > overkill. I know this must really be boner of a newbie question, but I'm > baffled. Relax :-) The point is that Ada is a strict language. It does boundary checks etc and to do this it needs to know the size of the string. But you also have variable strings. Let me first show you an example: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure string_test is First_Name : String (1 .. 6) := "Preben"; Sirname : String (1 .. 7) := "Randhol"; -- Defining a String with fixed length Full_Name : String (1 .. 14); Variable : Unbounded_String; begin Full_Name := First_Name & " " & Sirname; -- Another way declare Name : String := First_Name & " " & Sirname; begin -- You can now use Name here. You don't have to say that -- it is 1 .. 14 because it will be defined as you use the := end; -- Another way using Unbounded string: Variable := To_Unbounded (First_Name & " "); Variable := Variable & To_Unbounded (Sirname); -- You see that you can now have a variable length string and -- Add parts as you like. end string_test; > > I look forward to you your response, > Justin > > -- Ada95 is good for you. http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf