Board index » delphi » How to pass an entire array to a Procedure

How to pass an entire array to a Procedure

Hello, I'm Amos

I would like to know how an entire array could be passed to a procedure.

If I wanted to pass this array then could it look like :

        Need to pass Score : Array[1..MaxRec] of integer;  {MaxRec = 500}

        Procedure Result(Score:Array ...     ?????   cannot!!!

        Help!!!!

Thanks.

 

Re:How to pass an entire array to a Procedure


wong boon hong (bhw...@singnet.com.sg) wrote:
: Hello, I'm Amos
:
: I would like to know how an entire array could be passed to a procedure.
:
: If I wanted to pass this array then could it look like :
:
:       Need to pass Score : Array[1..MaxRec] of integer;  {MaxRec = 500}
:
:       Procedure Result(Score:Array ...     ?????   cannot!!!
:

Type
MyArray=Array[1..MaxRec] of integer;

Procedure Score(Var AnArray:MyArray);
{or
Procedure Score(Const AnArray:MyArray);

Quote
}

{or
Procedure Score(AnArray:MyArray);
Quote
}

Var
i:word;
Begin
   for i := 1 to MaxRec do begin
     Writeln(AnArray[i]);
   end;
End;

The Chief
--------
Dr. A{*word*73}la A. Olowofoyeku (The African Chief)
Email: la...@keele.ac.uk
Author of: Chief's Installer Pro 3.10 for Win16 and Win32:
           Winner of PC PLUS Magazine Gold Award (April 1995 U.K. edition)
           http://ourworld.compuserve.com/homepages/African_Chief/
           ftp://ftp.simtel.net/pub/simtelnet/win3/install/chief310.zip  

Re:How to pass an entire array to a Procedure


wong boon hong (bhw...@singnet.com.sg) wrote:

Quote
> I would like to know how an entire array could be passed to a procedure.

>    Need to pass Score : Array[1..MaxRec] of integer;  {MaxRec = 500}

>    Procedure Result(Score:Array ...     ?????   cannot!!!

Try this:

type
  TScore = Array[1..MaxRec] of integer;

Procedure Result(Score: TScore)

Good luck...

--
-Eddy Wibowo

Re:How to pass an entire array to a Procedure


On 30 Jan 1997, wong boon hong wrote:

Quote
> Hello, I'm Amos
> I would like to know how an entire array could be passed to a procedure.
> If I wanted to pass this array then could it look like :
> =09Need to pass Score : Array[1..MaxRec] of integer;  {MaxRec =3D 500}
> =09Procedure Result(Score:Array ...     =BB=BB=BB=BB=BB   cannot!!!
> =09Help!!!!

program my_prog;
const MaxRec=3D500;
uses ....
...
type my_array=3Darray[1..MaxRec] of integer;
var=20
    a:my_array;
...

procedure result (Score: my_array);
begin
..
end; { result }

begin {program}
   result ( a ) ;
end.

I recommend that you use declaration=20

 procedure result (var Score: my_array);
                   ***

instead of=20
  procedure result (Score: my_array);

It saves memory and program is faster

Other Threads