From: Anders Wirzenius <anders@no.email.thanks.invalid>
Subject: Re: range in ascii
Date: Thu, 31 Mar 2005 10:52:46 GMT
Date: 2005-03-31T10:52:46+00:00 [thread overview]
Message-ID: <upsxg2ikh.fsf@no.email.thanks.invalid> (raw)
In-Reply-To: 1112261828.853505.238490@f14g2000cwb.googlegroups.com
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)
> 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
next prev parent reply other threads:[~2005-03-31 10:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-22 15:26 range in ascii mieville
2005-03-22 15:43 ` Peter Hermann
2005-03-31 9:37 ` mieville
2005-03-31 10:52 ` Anders Wirzenius [this message]
2005-03-31 11:23 ` Alex R. Mosteo
2005-03-31 19:15 ` Jeffrey Carter
2005-03-22 17:32 ` Martin Dowie
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox