Board index » delphi » Arrays in procedures!!!!

Arrays in procedures!!!!

How do I store data in an array from a procedure or function:

PROCEDURE LoadPCX(PCXFilename : String; ArrayName : Array????);
I'm using an array with pointers so its defined like this:
Var Bar : BarPtr;

Please help... respond by email if possible.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
EMail: marsh...@pssnet.com
Watermarks: http://www.globalserve.net/~brent

 

Re:Arrays in procedures!!!!


Quote
In article <31F55A54.1...@pssnet.com> Marshall <marsh...@pssnet.com> writes:
>How do I store data in an array from a procedure or function:
>PROCEDURE LoadPCX(PCXFilename : String; ArrayName : Array????);
>I'm using an array with pointers so its defined like this:
>Var Bar : BarPtr;

Typically, an array is passed as a "var" parameter, and to satisfy the syntax
requirements of the language the array must be defined as a type, then the
typename can be used in the procedure declaration, viz:

        type
                humDingerArray = array [ 1..10 ] of humDinger;

        procedure LoadPCX(const PCXFileName: string;
                          var ArrayName: humDingerArray);

N.B. I took the liberty also of defining "PCXFileName" as a "const" parameter
which means that only the address of the value (4 bytes) rather than the value
itself (256) will be placed on the stack.

/mr/

Re:Arrays in procedures!!!!


Quote
Sundial Services wrote:

> In article <31F55A54.1...@pssnet.com> Marshall <marsh...@pssnet.com> writes:

> >How do I store data in an array from a procedure or function:

> >PROCEDURE LoadPCX(PCXFilename : String; ArrayName : Array????);
> >I'm using an array with pointers so its defined like this:
> >Var Bar : BarPtr;

> Typically, an array is passed as a "var" parameter, and to satisfy the syntax
> requirements of the language the array must be defined as a type, then the
> typename can be used in the procedure declaration, viz:

>         type
>                 humDingerArray = array [ 1..10 ] of humDinger;

>         procedure LoadPCX(const PCXFileName: string;
>                           var ArrayName: humDingerArray);

> N.B. I took the liberty also of defining "PCXFileName" as a "const" parameter
> which means that only the address of the value (4 bytes) rather than the value
> itself (256) will be placed on the stack.

> /mr/
Sundial Services wrote:

> In article <31F55A54.1...@pssnet.com> Marshall <marsh...@pssnet.com> writes:

> >How do I store data in an array from a procedure or function:

> >PROCEDURE LoadPCX(PCXFilename : String; ArrayName : Array????);
> >I'm using an array with pointers so its defined like this:
> >Var Bar : BarPtr;

> Typically, an array is passed as a "var" parameter, and to satisfy the syntax
> requirements of the language the array must be defined as a type, then the
> typename can be used in the procedure declaration, viz:

>         type
>                 humDingerArray = array [ 1..10 ] of humDinger;

>         procedure LoadPCX(const PCXFileName: string;
>                           var ArrayName: humDingerArray);

> N.B. I took the liberty also of defining "PCXFileName" as a "const" parameter
> which means that only the address of the value (4 bytes) rather than the value
> itself (256) will be placed on the stack.

There is just one problem with this... here is some of my actual code...

TYPE Bar = Array [0..320, 0..30] of byte;
     BarPtr = ^Bar;                  
{ I will have multiple arrays of different sizes to store graphics }

VAR BarArr : BarPtr;

Procedure LoadPCX(PCXName : String; Arr : Byte; Wid, Hei : Integer);

The BarPtr will change for every graphic the way I have it right now
and I can't seem to figure out any way of storing the data other than
arrays like this.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
EMail: marsh...@pssnet.com
Watermarks: http://www.globalserve.net/~brent

Re:Arrays in procedures!!!!


Quote
> > >How do I store data in an array from a procedure or function:
> > Typically, an array is passed as a "var" parameter, and to satisfy the syntax
> > requirements of the language the array must be defined as a type, then the
> > typename can be used in the procedure declaration, viz:
> >         type
> >                 humDingerArray = array [ 1..10 ] of humDinger;
> >         procedure LoadPCX(const PCXFileName: string;
> >                           var ArrayName: humDingerArray);

> > N.B. I took the liberty also of defining "PCXFileName" as a "const" parameter
> > which means that only the address of the value (4 bytes) rather than the value
> > itself (256) will be placed on the stack.

> There is just one problem with this... here is some of my actual code...

> TYPE Bar = Array [0..320, 0..30] of byte;
>      BarPtr = ^Bar;
> { I will have multiple arrays of different sizes to store graphics }

> VAR BarArr : BarPtr;

> Procedure LoadPCX(PCXName : String; Arr : Byte; Wid, Hei : Integer);

> The BarPtr will change for every graphic the way I have it right now
> and I can't seem to figure out any way of storing the data other than
> arrays like this.

   Then use an untyped parameter, plus parameter(s) to define which array
type or dimensions are being processed.  For that matter, why pass an
array parameter at all?  Since you're altering global data, why not just
pass enough information to define the address/bounds of the variable
data?

Other Threads