comp.lang.ada
 help / color / mirror / Atom feed
* passing an array
@ 1994-12-03 22:52 Bill Heiser
  1994-12-04 15:33 ` David Weller
  0 siblings, 1 reply; 2+ messages in thread
From: Bill Heiser @ 1994-12-03 22:52 UTC (permalink / raw)


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?

Thanks in advance.
Bill
-- 
Bill Heiser    heiser@acs.bu.edu, heiser@world.std.com
               Boston University, Boston MA   



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

* Re: passing an array
  1994-12-03 22:52 passing an array Bill Heiser
@ 1994-12-04 15:33 ` David Weller
  0 siblings, 0 replies; 2+ messages in thread
From: David Weller @ 1994-12-04 15:33 UTC (permalink / raw)


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   |



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

end of thread, other threads:[~1994-12-04 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-12-03 22:52 passing an array Bill Heiser
1994-12-04 15:33 ` David Weller

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