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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1f78990666319a12 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: range in ascii Date: Thu, 31 Mar 2005 13:23:43 +0200 Message-ID: <424BDDBF.9000903@mailinator.com> References: <1111505197.604268.101910@l41g2000cwc.googlegroups.com> <1112261828.853505.238490@f14g2000cwb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net A79Ji5Rxv5rZ9gzm2zGcQgkNDtV757uOt9fFUGMlf+f3+eMew= User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:10180 Date: 2005-03-31T13:23:43+02:00 List-Id: Anders Wirzenius wrote: > mieville@mac.com writes: > > >>Hi all, I now have my code to count frequency of letters in a text but >>I do not know how to read the command "enter" after I write my text. >>What I have now is CTRL+Q but of course is not an elegant solution and >>I know there is something easy but I cannot find it. Here below is my >>code if someone could help me in that single question I would be >>grateful. many thanks - sibyl >> >>with Text_Io; >>use Text_Io; >> >>with Ada.Integer_Text_Io; >>use Ada.Integer_Text_Io; >> >>procedure Comptelettretest is >> >> Char , char2 : Character; >> cod: integer ; >> subtype Lettre is Integer range 20..255; >> type Freq_Lettre is array (Lettre) of Integer; >> Count : Freq_Lettre:= (others => 0); >> >>begin >> >> Put_Line ("Entrer un text au choix et le terminer par 'CTRL/Q' et >>'enter' "); >> loop > > > Get_Immediate (Char); > Put (Char); > -- Get (Char) Mmmmm, what about the old Get_Line? Isn't it just the thing to use for enter-finished inputs? You'll get a string instead of a character, but iterating over its characters is just as easy. > > >> Get(Char); >> >> --how to escape from this instruction, I want to hit enter and >>have the list. > > > exit when Char = ASCII.CR; -- Works at least on Windows > > > >> exit when Char = ASCII.DC1; >> cod := CHARACTER'POS(CHAR); >> if cod in Lettre then >> Count(cod) := Count (cod) +1; >> end if; >> end loop; >> >>New_Line; >> Put_Line("Frequence des lettres"); >> New_Line; >> for cod in Lettre loop >> char2 := CHARACTER'VAL(cod); >> Put(char2); >> put(Count(cod)); >> New_Line; >> end loop; >> >>end Comptelettretest; > > > Anders