comp.lang.ada
 help / color / mirror / Atom feed
From: dweller@Starbase.NeoSoft.COM (David Weller)
Subject: Re: passing an array
Date: 4 Dec 1994 09:33:52 -0600
Date: 1994-12-04T09:33:52-06:00	[thread overview]
Message-ID: <3bsnh0$euf@Starbase.NeoSoft.COM> (raw)
In-Reply-To: 3bqss8$2v2@news.bu.edu

In article <3bqss8$2v2@news.bu.edu>, Bill Heiser <heiser@acs3.bu.edu> wrote:
>Given a setup like the following in one procedure:
>
>  type employee is
>    record
>      id: integer;
>      name: string(1..5);
>      dept: string(1..5);
>      salary: float;
>    end record;
>
>  emprec: employee;
>  emp_a: array(1..50) of employee;
>
>
>How can I pass the emp_a array to another function so that in the
>called procedure I can change emp_a records by referencing them
>as emp_a(n).id and so forth?
>

You've done a "style no-no" by creating an "anonymous array", the
line:
>  emp_a: array(1..50) of employee;

Is the culprit.  All you've created is an object that is an array of
50 employees.  While this is occasionally useful, you generally want
to associate object declarations with a type (that way you can pass
it as a parameter, as you're trying to do).  What you should do is
change that line into two lines:

  type emp_arr is array(1..50) of employee;
  emp_a: emp_arr;

 
Now you could create a subprogram that tosses your 50 employees about
with casual abandon :-)

Enjoy!


-- 
Proud (and vocal) member of Team Ada! (and Team OS/2)        ||This is not your
   	      Ada -- Very Cool.  Doesn't Suck.               ||  father's Ada 
For all sorts of interesting Ada tidbits, run the command:   ||________________
"finger dweller@starbase.neosoft.com | more" (or e-mail with "finger" as subj.)
	|"Quitting C++ isn't so difficult, provided you show as much |
	|	persistence stopping as you did starting." dweller   |



      reply	other threads:[~1994-12-04 15:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-03 22:52 passing an array Bill Heiser
1994-12-04 15:33 ` David Weller [this message]
replies disabled

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