comp.lang.ada
 help / color / mirror / Atom feed
From: John McCormick <MCCORMJW@splava.cc.plattsburgh.edu>
Subject: Re: INFO-ADA Digest V93 #56
Date: Mon, 8 Feb 1993 13:20 EST	[thread overview]
Message-ID: <01GUHB2EOPWG9QX30U@splava.cc.plattsburgh.edu> (raw)

In comp.lang.ada you write:
 
>Could somebody tell me (email please) why this programme,
>which compiles properly, seemingly stalls at the
>line indicated? i.e. I type in a line followed by <cr>,
>but nothing happens. What should happen is that this:
 
>*:: <the line that was typed>
 
>should be printed to the console, but isn't. And nothing
>happens. The input prompt:
 
>*>>
 
>is printed, then I can type something, but after <cr>
>nothing happens. :(
 
 
>With Text_IO; Use Text_IO;
 
>Procedure main is
 
>instr, tokstr : String(1..255);
 
String may not be the best data structure for your purpose.  If the domain
of instr and tokstr are small, an enumeration type is a better choice.  You
can instantiate an I/O package for your enumeration type.  Its Get
procedure acts more like the ones for numbers. No problems with mixing Gets
and Get_Lines.  No problems with line terminators.  No problems with upper-
or lowercase. You can even use the DATA_ERROR exception to validate your
input.  If you need a string later, there is always 'Image to convert
enumeration values to string values.  

I always tell my students to try to use enumeration types rather than
strings.

John


Note: 17 line signature follows
\f
===========================================================================
=  John W. McCormick                   Phone   (518) 564-2785             =
=  Computer Science Department         FAX     (518) 564-7827             =
=  State University of New York      mccormjw@snyplava.bitnet             =
=  Plattsburgh, NY  12901            mccormjw@splava.cc.plattsburgh.edu   =
=      USA                                                                =
=                           SUNY Plattsburgh                              =
=                                where                                    =
=       Computers + Model Railroading = Digitally Controlled Trains       =
=                                                                         =
=                        *      *     *                                   =
=                                          *                              =
=                                             *                           =
=          ##                           ##    T                           =
=        ######_########_########_#####_#########-                        =
=         o  o   o    o   o    o   o o  oo OOOO oo\                       =
===========================================================================

                 reply	other threads:[~1993-02-08 18:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox