Adding and Deleting Records.. I am stuck :(

Hi.
I am trying to create two procedures for my database to add and delete record.

PROCEDURE Add_Record(key : Key_T; VAR k : DB_T);

k.Size := k.Size + 1;
k.Recs[k.Size] := key;

the process is not working. i have declared size as integer and there is Key_T = RECORD and DB_T is a array of the record size.

can anyone plz help :(





Comments

  • : Hi.
    : I am trying to create two procedures for my database to add and delete record.
    :
    : PROCEDURE Add_Record(key : Key_T; VAR k : DB_T);
    :
    : k.Size := k.Size + 1;
    : k.Recs[k.Size] := key;
    :
    : the process is not working. i have declared size as integer and there is Key_T = RECORD and DB_T is a array of the record size.
    :
    : can anyone plz help :(
    :
    :
    If you declared DB_T as follows:
    [code]
    DB_T = record
    Size: integer;
    Recs: array of Key_T;
    [/code]
    then there is no relationship between size and the number of records. If you add, or delete a record you need to update both the size and the number of elements in the Recs. In most Pascal variants the latter is done using SetLength().
    Certain Pascals (like Turbo Pascal) don't support dynamic arrays. For those you need to use a Linked-List instead.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion