comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Beginner's questions
Date: 1999/05/03
Date: 1999-05-03T00:00:00+00:00	[thread overview]
Message-ID: <7gkq7e$dcm$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 372da49c.12366381@news.rwth-aachen.de

In article <372da49c.12366381@news.rwth-aachen.de>,
  marcoschmidt@geocities.com wrote:
> I have to write my first longer program in Ada and could resolve all
> questions except for those two using the reference manual. Maybe
> someone could help me here... I'm using GNAT 3.11p for NT.
>
> 1) I couldn't find out how to use bitwise operations "and" and "or"
> (which would be "and" / "or" in Pascal and "&" / "|" in C). Do I have
> to include a certain package?

There are two ways to perform bitwise operations. One way is to use modular
types, and the other is to use packed arrays of booleans. Which one is best
for you to use depends on what you want to do with your objects *besides* the
bitwise operations.


> 2) I want to use a fixed-size array of constant strings to store some
> names which do not all have the same length, but no name is longer
..
> is raised. How should I do it?

If you won't need to change the contents of the strings, one quick-and-dirty
method is the following:

type String_Ptr is access String;
type String_Ptr_List is array (1..3) of String_Ptr;
String_List : constant String_Ptr_List :=
   (new String'("Hi there!"),
    new String'("How are you doing?"),
    new String'("Why, I'm fine. How are you?")
   );

Don't do this in a loop or subroutine, unless you are prepared to deallocate
the strings when you are done. But as one-time-only code on an OS that cleans
up process resources after termination this often does the trick for me.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1999-05-03  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-02  0:00 Beginner's questions Marco Schmidt
1999-05-02  0:00 ` Matthew Heaney
1999-05-03  0:00   ` Marco Schmidt
1999-05-03  0:00     ` Matthew Heaney
1999-05-03  0:00 ` dennison [this message]
1999-05-04  0:00   ` Tucker Taft
1999-05-04  0:00     ` dennison
1999-05-10  0:00       ` Tucker Taft
1999-05-03  0:00 ` Andreas Winckler
1999-05-03  0:00   ` Matthew Heaney
1999-05-03  0:00     ` Andreas Winckler
1999-05-03  0:00       ` David Starner
1999-05-04  0:00         ` Andreas Winckler
1999-05-04  0:00           ` Larry Kilgallen
1999-05-04  0:00             ` Martin C. Carlisle
1999-05-04  0:00               ` Larry Kilgallen
1999-05-05  0:00                 ` Andreas Winckler
1999-05-04  0:00 ` czgrr
1999-05-04  0:00   ` Nick Roberts
1999-05-07  0:00     ` Robert Dewar
1999-05-07  0:00       ` David Starner
1999-05-08  0:00         ` ak
replies disabled

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