Board index » delphi » Two Dimensional arrays

Two Dimensional arrays

Hie I want to create a two dimensional array for creating a cd wall.
But I m unsure on how to go abou this exactly. What this array is
suppose to be able to do , is allow entry of data in the array however
it will only be able to store a maximum of 15 items/entries at each
location (eg 15 cds in row 1 column 3) how do i go about doing this?
Furthermore this will be displayed on a stringgrid. So far my codes
are in a newly created processunit

unit CDMRKTProcessUnit;

interface

const
  MaxNumRows=15;
  MaxNumColumns=45;

type
  TEntries=(clCDCode,clCDCode,clCDTitle,clCDDescription, clCDCategory,
             clCDManufacturer,clCDToAdd, clRow, clColumn,CDPrice);
  TCDRecord=Record
    CDCode,CDTitle,CDManufacturer,CDDescription: string;
    CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
    CDPrice: currency;
end;
TCDArray=array[1.. MaxNumRows;1..MaxNumColumns]of TCDRecord;

var
  CDArray: TCDArray;
  NumCDs,CurrentCDs:integer;

procedure Initialisation;

function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
               CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
               CDPrice: currency;):boolean;

implementation

procedure Initialisation
begin
  NumCDs:=0;
  CurrentCDs:=0;
end;

function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
               CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
               CDPrice: currency;):boolean;

this is as much as i have done and i am unsure on how to go on? Could
someone help?
thanks
Justin

 

Re:Two Dimensional arrays


Quote
> this is as much as i have done and i am unsure on how to go on? Could
> someone help?
> function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
>                CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
>                CDPrice: currency;):boolean;

begin
cdarray[cdrow,cdcolumn].cdcode:=acdcode;
cdarray[cdrow,cdcolumn].cdTitle:=acdtitle;
etc. etc. etc.
end;

Cheers,
Nicholas Sherlock

Re:Two Dimensional arrays


Thanks mate..will give it a try
justin
Quote
"Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message <news:b84vko$l8b$1@lust.ihug.co.nz>...
> > this is as much as i have done and i am unsure on how to go on? Could
> > someone help?

> > function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
> >                CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
> >                CDPrice: currency;):boolean;
> begin
> cdarray[cdrow,cdcolumn].cdcode:=acdcode;
> cdarray[cdrow,cdcolumn].cdTitle:=acdtitle;
> etc. etc. etc.
> end;

> Cheers,
> Nicholas Sherlock

Re:Two Dimensional arrays


Just wondering as well Nicholas...what does the code u give me do?
Just for understanding sake
cheers
Justin
Quote
"Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message <news:b84vko$l8b$1@lust.ihug.co.nz>...
> > this is as much as i have done and i am unsure on how to go on? Could
> > someone help?

> > function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
> >                CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
> >                CDPrice: currency;):boolean;
> begin
> cdarray[cdrow,cdcolumn].cdcode:=acdcode;
> cdarray[cdrow,cdcolumn].cdTitle:=acdtitle;
> etc. etc. etc.
> end;

> Cheers,
> Nicholas Sherlock

Re:Two Dimensional arrays


Umm, well I used your code to make it, I assumed that you were wanting to
put the details of a CD into a certain position on the array. This code sets
the cdcode and cdtitle of the cd in the array position specified by
CDRow/CDColumn in Addcd() to what you pass it......

Cheers,
Nicholas Sherlock

Quote
"justin" <j...@hotmail.com> wrote in message

news:61a979f4.0304222243.387ef5e2@posting.google.com...
Quote
> Just wondering as well Nicholas...what does the code u give me do?
> Just for understanding sake
> cheers
> Justin

> "Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message

<news:b84vko$l8b$1@lust.ihug.co.nz>...
Quote
> > > this is as much as i have done and i am unsure on how to go on? Could
> > > someone help?

> > > function AddCd(aCDCode,CDTitle,CDManufacturer,CDDescription: string;
> > >                CDCategory,CDNumber, CDToAdd, CDRow, CDColumn: integer;
> > >                CDPrice: currency;):boolean;
> > begin
> > cdarray[cdrow,cdcolumn].cdcode:=acdcode;
> > cdarray[cdrow,cdcolumn].cdTitle:=acdtitle;
> > etc. etc. etc.
> > end;

> > Cheers,
> > Nicholas Sherlock

Other Threads