print out an Array

conchale_at_mac.com
Date: 01/31/05


Date: 31 Jan 2005 04:25:42 -0800

Hello all, I'm new to this and comming from Java environment. I have
this code to convert bytes to bits but I dont know what to put in the
last line of code to get on the screen my converted number. Thanks for
any help
----------------------------------------------------------
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_text_Io; use Ada.Integer_text_Io;

procedure Pas3 is

subtype Octet is Integer range 0..255;
subtype Bit is Integer range 0..1;
type Tab_Bits is array (0 .. 7) of Bit;

function Octet_Vers_Bits (Oc : Octet )
return Tab_Bits is
Resultat : Tab_Bits;
N : Octet;

begin
N := Oc;
for I in reverse 0..7 loop
if ( N mod 2 = 1 ) then
Resultat(I) := 1;
else
Resultat(I) := 0;
end if;
N := N / 2;
end loop;
return Resultat;
end Octet_Vers_Bits;

t1 : Tab_bits;
x : integer;

begin
Put (" donner x: ");
Get(x);

for I in 0 .. 7 loop
t1 := Octet_Vers_Bits(x);
Put(Bit(x)); ----------------> here is the problem, what should I
put here.
   end loop;
end Pas3 ;



Relevant Pages

  • Printing out an Array
    ... subtype Octet is Integer range 0..255; ... Resultat: Tab_Bits; ... for I in reverse 0..7 loop ...
    (comp.lang.ada)
  • Re: Printing out an Array
    ... > subtype Octet is Integer range 0..255; ... > for I in reverse 0..7 loop ... Option 2 is more difficult but you can use formating options. ...
    (comp.lang.ada)
  • Re: loop variable
    ... Something like '1..10' is shorthand for 'Integer range 1..10' and ... The declaration of a loop control variable is the only case in Ada where you can define an object without giving its type in the same declaration - and it's unfortunate. ...
    (comp.lang.ada)
  • Re: how to import a package
    ... both C and D are of the same named type - even though the type T has an anonymous type as an index range. ... Just nit-picking, the index type of T is not anonymous, it is Standard.Integer by default, therefore the aboved declaration is not equivalent. ... type T is array (Integer range 0..5) of Integer; ... for I in Integer range 1..10 loop ...
    (comp.lang.ada)