comp.lang.ada
 help / color / mirror / Atom feed
* Problems with records--IMPORTANT
@ 1998-02-01  0:00 Dami�n Company
  1998-02-02  0:00 ` bklungle
  0 siblings, 1 reply; 6+ messages in thread
From: Dami�n Company @ 1998-02-01  0:00 UTC (permalink / raw)



Well I'm new at programmin and I have very little experience. But this
question is important for me as I have to present a practice at school!!!!
What does GNAT mean when "says" that there's a
            >>> invalid prefix in selected component "r"
I adjunt my listings

GNAT 3.10p (970814) Copyright 1992-1997 Free Software Foundation, Inc.
Compiling: llegir_racionals.adb (source file time stamp: 1998-02-01
00:50:20)
     1. package body llegir_racionals is
     2.    procedure get(op:out operacio)is
     3.       c:character;
     4.       i:integer:=1;
     5.    begin
     6.       get(c);
     7.       while c/='=' loop
     8.          op(i):=c;i:=i+1;
     9.       end loop;
    10.    end get;
    11.
    12.    procedure transformar(o:in operacio;r,s:out racional;op:out
character)is
    13.       n,d:integer:=0;i:integer:=1;
    14.       type num_text is array (1..10) of character;
    15.       num:num_text:=(1..10=>' ');
    16.       ord,l:integer:=1;nums:integer range 0..4:=0;
    17.       type taula_conv is array (0..9) of character;
    18.       t:constant taula_conv:="0123456789";j:integer:=0;p,k:integer;
    19.    begin
    20.       while o(i)/='=' loop
    21.          while o(i)/='+' or o(i)/='/' or o(i)/='-' or o(i)/='*' loop
    22.             num(l):=o(i);
    23.             l:=l+1;
    24.          end loop;
    25.          nums:=nums+1;
    26.          ord:=0;p:=1;
    27.          while l>0 loop
    28.             case nums is
    29.                when 1 =>
    30.                   j:=0;
    31.                   while num(l)/=t(j) loop
    32.                      j:=j+1;
    33.                   end loop;
    34.                   k:=0;
    35.                   while k<ord loop
    36.                      p:=p*10;
    37.                   end loop;
    38.                   n:=n+j*1;
    39.                when 3=>
    40.                   j:=0;
    41.                   while num(l)/=t(j) loop
    42.                      j:=j+1;
    43.                   end loop;
    44.                   k:=0;
    45.                   while k<ord loop
    46.                      p:=p*10;
    47.                   end loop;
    48.                   n:=n+j*1;
    49.                when 2=>
    50.                   j:=0;
    51.                   while num(l)/=t(j) loop
    52.                      j:=j+1;
    53.                   end loop;
    54.                   k:=0;
    55.                   while k<ord loop
    56.                      p:=p*10;
    57.                   end loop;
    58.                   d:=d+j*1;
    59.                when 4=>
    60.                   j:=0;
    61.                   while num(l)/=t(j) loop
    62.                      j:=j+1;
    63.                   end loop;
    64.                   k:=0;
    65.                   while k<ord loop
    66.                      p:=p*10;
    67.                   end loop;
    68.                   d:=d+j*1;
    69.                when others=> null;
    70.                end case;
    71.             l:=l-1;
    72.          end loop;
    73.          case nums is
    74.             when 1=>null;
    75.             when 2=>r.n:=n;r.d:=d;op:=o(i);
                            1      2
        >>> invalid prefix in selected component "r"
        >>> invalid prefix in selected component "r"
    76.             when 3=>null;
    77.             when 4=>s.n:=n;s.d:=d;
                            1      2
        >>> invalid prefix in selected component "s"
        >>> invalid prefix in selected component "s"
    78.             when others =>null;
    79.          end case;
    80.          i:=i+1;
    81.       end loop;
    82.    end transformar;
    83. end llegir_racionals;
 83 lines: 4 errors

I defined racional as
 type racional is
      record
         n:integer;
         d:integer;
      end record;


If someone bothers to answer
THANKS






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems with records--IMPORTANT
  1998-02-01  0:00 Problems with records--IMPORTANT Dami�n Company
@ 1998-02-02  0:00 ` bklungle
  1998-02-04  0:00   ` Nick Roberts
  1998-02-05  0:00   ` Casper
  0 siblings, 2 replies; 6+ messages in thread
From: bklungle @ 1998-02-02  0:00 UTC (permalink / raw)



Very difficult to read the code with out spacing. Also some things were
missing. Here is your code, slightly modified to make it compile
successfully.

cheers...bob


package rational is

   type racional is
      record
         n:integer;
         d:integer;
      end record;

   type operacio is array(1..50) of character;

   procedure get(op : out operacio);

   procedure transformar
       (
          o    : in operacio;
          r, s : out racional;
          op   : out character
       );
 
end rational;



with Ada.text_io;

package body rational is

   package tio renames Ada.text_io;

   procedure get(op : out operacio) is
      c : character;
      i : integer := 1;
   begin
      tio.get(c);
      while c /= '=' loop
         op(i) := c;
         i := i + 1;
      end loop;
   end get;

   procedure transformar
       (
          o    : in operacio; 
          r, s : out racional; 
          op   : out character
       ) is
      n, d : integer := 0;
      i    : integer := 1;
      type num_text is array (1..10) of character;
      num  : num_text  := (1..10 => ' ');
      ord, l : integer := 1;
      nums   : integer range 0..4 := 0;
      type taula_conv is array (0..9) of character;
      t : constant taula_conv := "0123456789";
      j :integer := 0;
      p,k : integer;
   begin
      while o(i) /= '=' loop
         while o(i) /= '+' or o(i) /= '/' or o(i) /= '-' or o(i) /= '*'
loop
            num(l) := o(i);
            l := l + 1;
         end loop;
         nums := nums + 1;
         ord  := 0;
         p    := 1;
         while l > 0 loop
            case nums is
               when 1 =>
                  j := 0;
                  while num(l) /= t(j) loop
                     j := j + 1;
                  end loop;
                  k := 0;
                  while k < ord loop
                     p := p * 10;
                  end loop;
                  n := n + j * 1;
               when 3 =>
                  j := 0;
                  while num(l) /= t(j) loop
                     j := j + 1;
                  end loop;
                  k := 0;
                  while k < ord loop
                     p := p * 10;
                  end loop;
                  n := n + j * 1;
               when 2 =>
                  j := 0;
                  while num(l) /= t(j) loop
                     j := j + 1;
                  end loop;
                  k := 0;
                  while k < ord loop
                     p := p * 10;
                  end loop;
                  d := d + j * 1;
               when 4 =>
                  j := 0;
                  while num(l) /= t(j) loop
                     j := j + 1;
                  end loop;
                  k := 0;
                  while k < ord loop
                     p := p * 10;
                  end loop;
                  d := d + j * 1;
               when others => null;
            end case;
            l := l - 1;
         end loop;
         case nums is
            when 1 => null;
            when 2 => r.n := n;
                      r.d := d;
                      op  := o(i);
            when 3 =>null;
            when 4 => s.n := n;
                      s.d := d;
            when others => null;
         end case;
         i := i + 1;
      end loop;
   end transformar;
end rational;


gcc -c -g rational.adb
linux:~/atest>

As you can see, it compiled OK under GNAT 3.09

> Well I'm new at programmin and I have very little experience. But this
> question is important for me as I have to present a practice at
school!!!!
> What does GNAT mean when "says" that there's a
>             >>> invalid prefix in selected component "r"
> I adjunt my listings
> 
> GNAT 3.10p (970814) Copyright 1992-1997 Free Software Foundation, Inc.
> Compiling: llegir_racionals.adb (source file time stamp: 1998-02-01
> 00:50:20)
>      1. package body llegir_racionals is
>      2.    procedure get(op:out operacio)is
>      3.       c:character;
>      4.       i:integer:=1;
>      5.    begin
>      6.       get(c);
>      7.       while c/='=' loop
>      8.          op(i):=c;i:=i+1;
>      9.       end loop;
>     10.    end get;
>     11.
>     12.    procedure transformar(o:in operacio;r,s:out racional;op:out
> character)is
>     13.       n,d:integer:=0;i:integer:=1;
>     14.       type num_text is array (1..10) of character;
>     15.       num:num_text:=(1..10=>' ');
>     16.       ord,l:integer:=1;nums:integer range 0..4:=0;
>     17.       type taula_conv is array (0..9) of character;
>     18.       t:constant
taula_conv:="0123456789";j:integer:=0;p,k:integer;
>     19.    begin
>     20.       while o(i)/='=' loop
>     21.          while o(i)/='+' or o(i)/='/' or o(i)/='-' or o(i)/='*'
loop
>     22.             num(l):=o(i);
>     23.             l:=l+1;
>     24.          end loop;
>     25.          nums:=nums+1;
>     26.          ord:=0;p:=1;
>     27.          while l>0 loop
>     28.             case nums is
>     29.                when 1 =>
>     30.                   j:=0;
>     31.                   while num(l)/=t(j) loop
>     32.                      j:=j+1;
>     33.                   end loop;
>     34.                   k:=0;
>     35.                   while k<ord loop
>     36.                      p:=p*10;
>     37.                   end loop;
>     38.                   n:=n+j*1;
>     39.                when 3=>
>     40.                   j:=0;
>     41.                   while num(l)/=t(j) loop
>     42.                      j:=j+1;
>     43.                   end loop;
>     44.                   k:=0;
>     45.                   while k<ord loop
>     46.                      p:=p*10;
>     47.                   end loop;
>     48.                   n:=n+j*1;
>     49.                when 2=>
>     50.                   j:=0;
>     51.                   while num(l)/=t(j) loop
>     52.                      j:=j+1;
>     53.                   end loop;
>     54.                   k:=0;
>     55.                   while k<ord loop
>     56.                      p:=p*10;
>     57.                   end loop;
>     58.                   d:=d+j*1;
>     59.                when 4=>
>     60.                   j:=0;
>     61.                   while num(l)/=t(j) loop
>     62.                      j:=j+1;
>     63.                   end loop;
>     64.                   k:=0;
>     65.                   while k<ord loop
>     66.                      p:=p*10;
>     67.                   end loop;
>     68.                   d:=d+j*1;
>     69.                when others=> null;
>     70.                end case;
>     71.             l:=l-1;
>     72.          end loop;
>     73.          case nums is
>     74.             when 1=>null;
>     75.             when 2=>r.n:=n;r.d:=d;op:=o(i);
>                             1      2
>         >>> invalid prefix in selected component "r"
>         >>> invalid prefix in selected component "r"
>     76.             when 3=>null;
>     77.             when 4=>s.n:=n;s.d:=d;
>                             1      2
>         >>> invalid prefix in selected component "s"
>         >>> invalid prefix in selected component "s"
>     78.             when others =>null;
>     79.          end case;
>     80.          i:=i+1;
>     81.       end loop;
>     82.    end transformar;
>     83. end llegir_racionals;
>  83 lines: 4 errors
> 
> I defined racional as
>  type racional is
>       record
>          n:integer;
>          d:integer;
>       end record;
> 
> 
> If someone bothers to answer
> THANKS
> 
> 
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems with records--IMPORTANT
  1998-02-02  0:00 ` bklungle
@ 1998-02-04  0:00   ` Nick Roberts
  1998-02-05  0:00     ` Simon Wright
  1998-02-05  0:00     ` bklungle
  1998-02-05  0:00   ` Casper
  1 sibling, 2 replies; 6+ messages in thread
From: Nick Roberts @ 1998-02-04  0:00 UTC (permalink / raw)



But Bob: you don't appear to have changed anything _but_ the spacing!  Do
we infer that the reason for Damian's errors is a difference in GANT
version (from your v3.09)?  I cannot see anything wrong with the flagged
code.

-- 

== Nick Roberts ================================================
== Croydon, UK                       ===========================
==                                              ================
== Proprietor, ThoughtWing Software                   ==========
== Independent Software Development Consultant            ======
== Nick.Roberts@dial.pipex.com                              ====
== Voicemail & Fax +44 181-405 1124                          ===
==                                                            ==
==           I live not in myself, but I become               ==
===          Portion of that around me; and to me             ==
====         High mountains are a feeling, but the hum        ==
=======      Of human cities torture.
===========                             -- Byron [Childe Harold]


bklungle <bklungle@ix.netcom.com> wrote in article
<01bd2fc3$8432eca0$0e2915c0@p5120>...
[...]
>          case nums is
>             when 1 => null;
>             when 2 => r.n := n;
>                       r.d := d;
>                       op  := o(i);
>             when 3 =>null;
>             when 4 => s.n := n;
>                       s.d := d;
>             when others => null;
>          end case;
[...]
> >     73.          case nums is
> >     74.             when 1=>null;
> >     75.             when 2=>r.n:=n;r.d:=d;op:=o(i);
> >                             1      2
> >         >>> invalid prefix in selected component "r"
> >         >>> invalid prefix in selected component "r"
> >     76.             when 3=>null;
> >     77.             when 4=>s.n:=n;s.d:=d;
> >                             1      2
> >         >>> invalid prefix in selected component "s"
> >         >>> invalid prefix in selected component "s"
> >     78.             when others =>null;
> >     79.          end case;





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems with records--IMPORTANT
  1998-02-02  0:00 ` bklungle
  1998-02-04  0:00   ` Nick Roberts
@ 1998-02-05  0:00   ` Casper
  1 sibling, 0 replies; 6+ messages in thread
From: Casper @ 1998-02-05  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 25 bytes --]


Casper is Dami�n






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems with records--IMPORTANT
  1998-02-04  0:00   ` Nick Roberts
@ 1998-02-05  0:00     ` Simon Wright
  1998-02-05  0:00     ` bklungle
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Wright @ 1998-02-05  0:00 UTC (permalink / raw)



"Nick Roberts" <Nick.Roberts@dial.pipex.com> writes:

> But Bob: you don't appear to have changed anything _but_ the spacing!  Do
> we infer that the reason for Damian's errors is a difference in GANT
> version (from your v3.09)?  I cannot see anything wrong with the flagged
> code.

Nor can I -- I deleted the procedure get, replaced operacio by string,
and it compiled (3.10p, i486-unknown-linux/2.7.2.1)

Damian, it would have helped ic you'd given us the package spec too.

-Simon




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problems with records--IMPORTANT
  1998-02-04  0:00   ` Nick Roberts
  1998-02-05  0:00     ` Simon Wright
@ 1998-02-05  0:00     ` bklungle
  1 sibling, 0 replies; 6+ messages in thread
From: bklungle @ 1998-02-05  0:00 UTC (permalink / raw)



But Nick,

As far as I could tell, there wasn't anything wrong with the code he gave
us. I can only assume that the stuff I added (type defs etc) to make it
compile (which were explicitly missing from what he gave) were incorrect
and the cause of the problem. Without more information than that given, I
can/could draw no further conclusions. That is why I inserted the code as
generated. Does that answer you?

bob

Nick Roberts <Nick.Roberts@dial.pipex.com> wrote in article
<01bd31b5$2b3b7380$85f882c1@xhv46.dial.pipex.com>...
> But Bob: you don't appear to have changed anything _but_ the spacing!  Do
> we infer that the reason for Damian's errors is a difference in GANT
> version (from your v3.09)?  I cannot see anything wrong with the flagged
> code.
> 
> -- 
> 
> == Nick Roberts ================================================
> == Croydon, UK                       ===========================
> ==                                              ================
> == Proprietor, ThoughtWing Software                   ==========
> == Independent Software Development Consultant            ======
> == Nick.Roberts@dial.pipex.com                              ====
> == Voicemail & Fax +44 181-405 1124                          ===
> ==                                                            ==
> ==           I live not in myself, but I become               ==
> ===          Portion of that around me; and to me             ==
> ====         High mountains are a feeling, but the hum        ==
> =======      Of human cities torture.
> ===========                             -- Byron [Childe Harold]
> 
> 
> bklungle <bklungle@ix.netcom.com> wrote in article
> <01bd2fc3$8432eca0$0e2915c0@p5120>...
> [...]
> >          case nums is
> >             when 1 => null;
> >             when 2 => r.n := n;
> >                       r.d := d;
> >                       op  := o(i);
> >             when 3 =>null;
> >             when 4 => s.n := n;
> >                       s.d := d;
> >             when others => null;
> >          end case;
> [...]
> > >     73.          case nums is
> > >     74.             when 1=>null;
> > >     75.             when 2=>r.n:=n;r.d:=d;op:=o(i);
> > >                             1      2
> > >         >>> invalid prefix in selected component "r"
> > >         >>> invalid prefix in selected component "r"
> > >     76.             when 3=>null;
> > >     77.             when 4=>s.n:=n;s.d:=d;
> > >                             1      2
> > >         >>> invalid prefix in selected component "s"
> > >         >>> invalid prefix in selected component "s"
> > >     78.             when others =>null;
> > >     79.          end case;
> 
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-02-05  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-01  0:00 Problems with records--IMPORTANT Dami�n Company
1998-02-02  0:00 ` bklungle
1998-02-04  0:00   ` Nick Roberts
1998-02-05  0:00     ` Simon Wright
1998-02-05  0:00     ` bklungle
1998-02-05  0:00   ` Casper

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