* 3 questions from a beginner @ 1998-12-06 0:00 Pierre 1998-12-06 0:00 ` Tom Moran ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Pierre @ 1998-12-06 0:00 UTC (permalink / raw) 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) 2) how we compare 2 strings letter by letter ? 3) how we use the function TO_UPPER for only the first letter of a string. Thank you in advance Pierre ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 3 questions from a beginner 1998-12-06 0:00 3 questions from a beginner Pierre @ 1998-12-06 0:00 ` Tom Moran 1998-12-06 0:00 ` Pierre 1998-12-07 0:00 ` david.c.hoos.sr 1998-12-07 0:00 ` david.c.hoos.sr 2 siblings, 1 reply; 6+ messages in thread From: Tom Moran @ 1998-12-06 0:00 UTC (permalink / raw) >2) how we compare 2 strings letter by letter ? if A = B then >3) how we use the function TO_UPPER for only the first letter of a string. if To_Upper(S(1)) = 'A' then assuming S's first index is 1. Use S'first to be more general. I don't understand your first question. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 3 questions from a beginner 1998-12-06 0:00 ` Tom Moran @ 1998-12-06 0:00 ` Pierre 1998-12-07 0:00 ` Matthew Heaney 0 siblings, 1 reply; 6+ messages in thread From: Pierre @ 1998-12-06 0:00 UTC (permalink / raw) Can you give me an example where there is RECORD and how to ask the user to fill the RECORD ?? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 3 questions from a beginner 1998-12-06 0:00 ` Pierre @ 1998-12-07 0:00 ` Matthew Heaney 0 siblings, 0 replies; 6+ messages in thread From: Matthew Heaney @ 1998-12-07 0:00 UTC (permalink / raw) "Pierre" <chuu@club-internet.fr> writes: > Can you give me an example where there is RECORD and how to ask the user to > fill the RECORD ?? What on earth do you mean? And why are you CAPITALIZING record? Do you mean how to assign one record to another? What's wrong with assignment? declare type Point is record X, Y : Integer; end record; P1 : constant Point := (1, 2); P2 : constant Point := P1; begin Do you mean how to use Text_IO to read in a record? If so, then use Text_IO to read in each record component. You have to be more specific if you want your questions answered. Je ne parle pas francais, mais je crois qu'il y a une newsgroup avec le nom <news:fr.comp.lang.ada>. Peut-etre vous pouvez y demander vos questions. (Un jour, je voudrais apprendre le francais. J'espere que vous pouvez me comprendre.) Matt ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 3 questions from a beginner 1998-12-06 0:00 3 questions from a beginner Pierre 1998-12-06 0:00 ` Tom Moran @ 1998-12-07 0:00 ` david.c.hoos.sr 1998-12-07 0:00 ` david.c.hoos.sr 2 siblings, 0 replies; 6+ messages in thread From: david.c.hoos.sr @ 1998-12-07 0:00 UTC (permalink / raw) To: chuu In article <74cdt6$ni3$1@front4.grolier.fr>, "Pierre" <chuu@club-internet.fr> 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 3 questions from a beginner 1998-12-06 0:00 3 questions from a beginner Pierre 1998-12-06 0:00 ` Tom Moran 1998-12-07 0:00 ` david.c.hoos.sr @ 1998-12-07 0:00 ` david.c.hoos.sr 2 siblings, 0 replies; 6+ messages in thread From: david.c.hoos.sr @ 1998-12-07 0:00 UTC (permalink / raw) To: chuu In article <74cdt6$ni3$1@front4.grolier.fr>, "Pierre" <chuu@club-internet.fr> 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) > In my earlier reply, I gave an example of Input, but not Output from the record type I furnished in the example. Here's an Output example: Ada.TexT_IO.Put_Line ("Name :" & My_Object.Name (My_Object.Name'First .. My_Object.Name_Last)); Ada.TexT_IO.Put_Line ("Address:" & My_Object.Address (My_Object.Address'First .. My_Object.Address_Last)); > 2) how we compare 2 strings letter by letter ? > > 3) how we use the function TO_UPPER for only the first letter of a string. > > Thank you in advance > > Pierre > > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1998-12-07 0:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1998-12-06 0:00 3 questions from a beginner Pierre 1998-12-06 0:00 ` Tom Moran 1998-12-06 0:00 ` Pierre 1998-12-07 0:00 ` Matthew Heaney 1998-12-07 0:00 ` david.c.hoos.sr 1998-12-07 0:00 ` david.c.hoos.sr
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox