comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: How would i keep 'records' in ADA ?
Date: Sun, 10 Mar 2002 02:00:27 GMT
Date: 2002-03-10T02:00:27+00:00	[thread overview]
Message-ID: <%6zi8.1520$rq2.1125284992@newssvr14.news.prodigy.com> (raw)
In-Reply-To: a6e9ko$b6a$1@knossos.btinternet.com

>holds information such as records of customers :- name, address, tel no.
>...
>i will have to use arrays and records right ? adding customer details is
  The information for one customer is heterogeneous - name string, phone
number, etc, so a record is appropriate.  The set of customers is
homogeneous - all customers are equivalent, so an array is appropriate.
If you want to save the data from one run of the program to another
you'll need to write the array of records to a file when the program
stops, and read back in next time the program starts.

>but deleting, im not sure about.  Do i just replace record for that
>customer with null statements / space character / junk
  The easiest is to just mark that customer record somehow as "empty".
Perhaps something as simple as changing the first character in the
customer's name to '-'.  Then periodically copy the database, except for
the "empty" records, to squeeze out the "bubbles".  That gets a bit
painful if the database is very large, however.  Then you might use
an available-space list:  Keep track of the first record number (index
into the array of customer records) that is "empty".  Make a field
in that empty record contain the record number of the next empty record,
and so on.  When it's time to add a new customer, put him in the first
empty record, and set the First_Empty_Record variable to point to the
next empty slot.
  This is the sort of stuff it's a whole lot quicker to learn from a
teacher or a book, than to re-invent by yourself.

>would i have to actually get rid of that element in the array ?
  If an array is a series of contiguous bits, you can't actually get rid
of an element (short of pulling out memory chips).  You can only mark it
in some way, or you can create a new array based on the old array.



  reply	other threads:[~2002-03-10  2:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-09 22:35 How would i keep 'records' in ADA ? Jim
2002-03-09 23:29 ` chris.danx
2002-03-09 23:32   ` chris.danx
2002-03-10  0:33     ` Jim
2002-03-10  2:00       ` tmoran [this message]
2002-03-10  6:51       ` Jeffrey Carter
2002-03-10 12:14       ` rmoldskr
2002-03-11 15:33         ` Marin David Condic
2002-03-10 12:45       ` chris.danx
2002-03-11 15:39         ` Marin David Condic
2002-03-10 12:03 ` David C. Hoos, Sr.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox