comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Roberts <nickroberts@callnetuk.com>
To: Sybs ALHABSHI <sybs@htsavoie.com>
Subject: Re: how do i include 111111 in an enumaration type ?
Date: 1999/10/12
Date: 1999-10-12T00:00:00+00:00	[thread overview]
Message-ID: <3802C50A.A5565DDA@callnetuk.com> (raw)
In-Reply-To: 7tsq3o$92p$1@minus.oleane.net

Sybs ALHABSHI wrote:
> In the enumaration type declaration, the string of caracters 000000 is taken
> as a numerical expression.
> 
> Can anyone explain how  I can get around this ?
> 
>         type webcolor is (FFFFFF, 000000);

Sybs,

I wonder if an enumeration type is what you are looking for here?  Take
a look at the following snippet of code.

   type Monochromatic_Level is mod 256; -- i.e. a byte

   type RGB_Color is
      record
         Red, Green, Blue: Monochromatic_Level;
      end record;

   Absolute_Black: constant RGB_Color := (16#00#, 16#00#, 16#00#);
   Absolute_White: constant RGB_Color := (16#FF#, 16#FF#, 16#FF#);

   function Hex_Image (Level: Monochromatic_Level) return String is
      Digit: constant array (Monochromatic_Level range 0..15) :=
         ('0', '1', '2', '3', '4', '5', '6', '7',
          '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
   begin
      return Digit(Level/16) & Digit(Level mod 16);
   end;

   function Hex_Image (RGB: RGB_Color) return String is
   begin
      return Hex_Image(RGB.Red) &
             Hex_Image(RGB.Green) &
             Hex_Image(RGB.Blue);
   end;

   ...

      Put(Web_File,"<BODY");
      Put(Web_File," bgcolor=#");
      Put(Web_File,Hex_Image(Background_Color));
      Put(Web_File," text=#");
      Put(Web_File,Hex_Image(Text_Color));
      ...

Hope this gives you a few ideas.

-- 
Nick Roberts
Computer Consultant (UK)
http://www.callnetuk.com/home/nickroberts
http://www.adapower.com/lab/adaos




       reply	other threads:[~1999-10-12  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7tsq3o$92p$1@minus.oleane.net>
1999-10-12  0:00 ` Nick Roberts [this message]
1999-10-14  0:00   ` how do i include 111111 in an enumaration type ? Sybs ALHABSHI
     [not found] ` <38021792_4@news1.prserv.net>
     [not found]   ` <slrn80495c.2a2.aidan@skinner.demon.co.uk>
1999-10-11  0:00     ` Keith Thompson
1999-10-12  0:00   ` Sybs ALHABSHI
1999-10-12  0:00     ` Lutz Donnerhacke
1999-10-12  0:00       ` Matthew Heaney
1999-10-12  0:00         ` Lutz Donnerhacke
1999-10-12  0:00           ` Ted Dennison
1999-10-13  0:00             ` Lutz Donnerhacke
1999-10-13  0:00               ` Matthew Heaney
1999-10-13  0:00                 ` Ted Dennison
1999-10-12  0:00           ` Ted Dennison
1999-10-12  0:00     ` Matthew Heaney
1999-10-12  0:00       ` Ehud Lamm
replies disabled

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