comp.lang.ada
 help / color / mirror / Atom feed
* how to make a record work??? any help would be greatly appreciated
@ 1999-09-14  0:00 irons
  1999-09-14  0:00 ` tmoran
  0 siblings, 1 reply; 2+ messages in thread
From: irons @ 1999-09-14  0:00 UTC (permalink / raw)


Hi

i'm getting a lot of errors and have a hard time in general trying to
make this simple program to work ..here's the code:

(the questions are written after the code)


with ada.text_io,ada.integer_text_io;
use ada.text_io,ada.integer_text_io;

procedure countries is


country_number:integer:=6;

   type a is array (1..6) of integer;
   type country is (syria,iran,turkey,egypt,jordan,saudi_arabia);
   type neighbouring_country is
       record
            country_name:string(1..2);
            syria_neighbour:string(1..1);
            iran_neighbor:string(1..1);
            turkey_neighbour:string(1..1);
            egypt_neighbour:string(1..1);
            jordan_neighbour:string(1..1);
            saudi_arabia_neighbour:string(1..1);
       end record;
    type my_country is array (1..6) of neighbouring_country;
    a(i):=my_country(i);

    begin

    for i in 1..6 loop
    get (my_country(i).neighbouring_country);
    put (my_country(i).country_name);
    get (my_country(i).syria_neighbour);
    put (my_country(i).syria_neighbour);
    get (my_country(i).iran_neighbor);
    put (my_country(i).iran_neighbor);
    get (my_country(i).turkey_neighbour);
    put (my_country(i).turkey_neighbour);
    get (my_country(i).egypt_neighbour);
    put (my_country(i).egypt_neighbour);
    get (my_country(i).jordan_neighbour);
    put (my_country(i).jordan_neighbour);
    get (my_country(i).saudi_arabia_neighbour);
    put (my_country(i).saudi_arabia_neighbour);
    new_line;
    end loop;

end countries;



the line "a(i):=my_country(i);" and everything inside the loop is not
working ...i'm trying to make a program that allows the user to input
the country prefix and if that country touchs other countries... for
example i'm trying to make the table look like this:

(this table just lists the country and if it touchs a neighbouring
country)

-----------------------------------------------------
contries|syria|iran|turkey|egypt|jordan|saudi_arabia|
-----------------------------------------------------
syria   | --  | no | yes  | no  | yes  |     no     |
-----------------------------------------------------
iran    | no  | -- | yes  | no  | no   |     no     |
-----------------------------------------------------
turkey  | yes | yes|  --  | no  | no   |     no     |
-----------------------------------------------------
egypt   | no  | no |  no  | --  | yes  |     no     |
-----------------------------------------------------
jordan  | yes | no |  no  | yes | --   |     yes    |
-----------------------------------------------------
saudi_ar| no  | no |  no  | no  | yes  |     --     |
-----------------------------------------------------

input would be: sy,--,no, yes,no yes,no (this is for syria) then i
would do the same all the way down to saudi_arabia .
for example: saudi_arabia's input would be it's prefix and it's if it
touchs another country or not
input: sa,no,no,no,yes,--

i know this looks like a lot ...any suggestions on how to make this
program work would be of great value to me and would be greatly
appreciated

my e-mail: okdeh@zebra.net







Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

* Re: how to make a record work??? any help would be greatly appreciated
  1999-09-14  0:00 how to make a record work??? any help would be greatly appreciated irons
@ 1999-09-14  0:00 ` tmoran
  0 siblings, 0 replies; 2+ messages in thread
From: tmoran @ 1999-09-14  0:00 UTC (permalink / raw)


>  type a is array (1..6) of integer;
>  type neighbouring_country is
>      record
>   type my_country is array (1..6) of neighbouring_country;
>   a(i):=my_country(i);
Attempts to store a neighbouring_country in an integer.
>   get (my_country(i).neighbouring_country);
Attempts to read into the "neighbouring_country" field of a
neighbouring_country - but there is no such field.
  If you want to input/output a rectangular table, why not
just use what you have - a rectangular array of yes/no/self?
  In any case, choose names that match the idea.  My_country
certainly sounds like a single, particular country, but actually
it's a type name.  A neighboring_country is also not a particular
country, but the name of a (different) type.  A
neighboring_country has all the info there is about a country,
namely a name and a list of its neighbors, but my_country has only
a list of neighbors, and no name.
  Look at "Ada Quality and Style" for good suggestions.




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

end of thread, other threads:[~1999-09-14  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-14  0:00 how to make a record work??? any help would be greatly appreciated irons
1999-09-14  0:00 ` tmoran

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