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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,94c814a9c8e91331 X-Google-Attributes: gid103376,public From: david.c.hoos.sr@ada95.com Subject: Re: 3 questions from a beginner Date: 1998/12/07 Message-ID: <74ggmh$bmk$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 419599732 References: <74cdt6$ni3$1@front4.grolier.fr> To: chuu@club-internet.fr X-Http-Proxy: 1.0 x14.dejanews.com:80 (Squid/1.1.22) for client 207.120.51.251 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Dec 07 12:12:02 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1998-12-07T00:00:00+00:00 List-Id: In article <74cdt6$ni3$1@front4.grolier.fr>, "Pierre" wrote: > Hello, > > I want to know 3 things : > > 1) how we use the composants from the type RECORD in I-O. Give me an example > please) > Supposing you have the type: type My_Type is record Name : String (1 .. 30); Name_Last : Natural; Address : String (1 .. 30; Address_Last : Natural; end record; and the object declaration: My_Object : My_Type; then you could read these records like this: Ada.Text_Io.Get_Line (Item => My_Object.Name, Last => Name_Last); Ada.Text_Io.Get_Line (Item => My_Object.Address, Last => Address_Last); > 2) how we compare 2 strings letter by letter ? > To compare the strings A and B, if you only wish to know for sure whether the two strings are equal, you can simply say if A = B then ..... When you ask "letter by letter" I assume you want to know the firsr letter which does not match. To do this, again between strtings named A and B, you could do this (assuming you have declared the variable First_Mismatch : Natural;, and that the two strings might not begin with identical indices): First_Mismatch := 0; for C in A'Range loop if A (C) /= B (B'First - A'First + C) then First_Mismatch := C; exit; end if; end loop; > 3) how we use the function TO_UPPER for only the first letter of a string. > I assume you mean the functions To_Upper declared in Ada.Characters.Handling. You will note that there are two overloaded functions, one for characters and one for strings. So, to change the first character of string A to upper case if it's lower, you could just say: A (A'First) := Ada.Characters.Handling.To_Upper (A (A'First)); > Thank you in advance > > Pierre > > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own