From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.2 required=5.0 tests=BAYES_00,RATWARE_MS_HASH, RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a83380f8e1854bc2 X-Google-Attributes: gid103376,public From: "bklungle" Subject: Re: Problems with records--IMPORTANT Date: 1998/02/02 Message-ID: <01bd2fc3$8432eca0$0e2915c0@p5120> X-Deja-AN: 321312992 References: <6b2hom$jt7$2@talia.mad.ibernet.es> Organization: B & D Associates X-NETCOM-Date: Mon Feb 02 2:09:35 AM PST 1998 Newsgroups: comp.lang.ada Date: 1998-02-02T02:09:35-08:00 List-Id: 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 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 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 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 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 > > >