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
justin wrote:
> 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;
> [...]

The "row" and "column" in this case represent a physical location on the
shelf:  it does not need to represent the physical storage of those records
in the computer and it should not.  (CD's /breed/ ... there are going to be
more than 15*45 of them.)

If you want to find the CD at a particular (row,col) location, the
appropriate routine simply searches through a list of records to find it.  
Your /conceptual/ view of the data .. as being a square matrix each
containing either zero or one records .. does not need to match its
physical storage in the memory of the computer and usually it does not.

----------------------------------
Fast automatic table repair at a click of a mouse!
http://www.sundialservices.com/products/chimneysweep

Other Threads