* Re: How would i keep 'records' in ADA ?
2002-03-10 0:33 ` Jim
@ 2002-03-10 2:00 ` tmoran
2002-03-10 6:51 ` Jeffrey Carter
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: tmoran @ 2002-03-10 2:00 UTC (permalink / raw)
>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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How would i keep 'records' in ADA ?
2002-03-10 0:33 ` Jim
2002-03-10 2:00 ` tmoran
@ 2002-03-10 6:51 ` Jeffrey Carter
2002-03-10 12:14 ` rmoldskr
2002-03-10 12:45 ` chris.danx
3 siblings, 0 replies; 11+ messages in thread
From: Jeffrey Carter @ 2002-03-10 6:51 UTC (permalink / raw)
If you mean how to keep them in memory, if you're doing additions and
deletions, a list is probably the best data structure. If you need to
search a large list for specific records, a skip list is good.
If you mean how to keep them when the program is not running, a file is
the answer.
If you mean how to keep them in the American Dental Association, this is
the wrong place to ask. Here we discuss the programming language Ada.
--
Jeff Carter
"Nobody expects the Spanish Inquisition!"
Monty Python's Flying Circus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How would i keep 'records' in ADA ?
2002-03-10 0:33 ` Jim
2002-03-10 2:00 ` tmoran
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
3 siblings, 1 reply; 11+ messages in thread
From: rmoldskr @ 2002-03-10 12:14 UTC (permalink / raw)
Jim <genx54321@hotmail.com> wrote:
[SNIP]
> i will have to use arrays and records right ? adding customer details is
> easy. but deleting, im not sure about. Do i just replace record for that
> customer with null statements / space character / junk (anything that gets
> rid of the details) or would i have to actually get rid of that element in
> the array ?
Another alternative is to use an external database, and perform SQL
calls upon that. Depending on the application, this might be the perfect
solution, or it might be overkill.
--
Leif Roar Moldskred
"Situation normal, cap'n. Spiralling out of control."
-- Jeff Smitch, Bone
> "chris.danx" <chris.danx@ntlworld.com> wrote in message
> news:LWwi8.7964$xO2.564676@news11-gui.server.ntli.net...
>>
>> "chris.danx" <chris.danx@ntlworld.com> wrote in message
>> news:XTwi8.7961$xO2.562660@news11-gui.server.ntli.net...
>> >
>> > "Jim" <genx54321@hotmail.com> wrote in message
>> > news:ab6237e2.0203091435.44234ae4@posting.google.com...
>> > > i dont mean records as part of the programming in ADA but if i wanted
>> > > to keep details of a person eg name, address, post code etc for a
>> > > program, how would i do it ?
>>
>> Can you elaborate on what you want? Now I think the stuff about files
>> wasn't what you wanted, but I'm not sure.
>>
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How would i keep 'records' in ADA ?
2002-03-10 12:14 ` rmoldskr
@ 2002-03-11 15:33 ` Marin David Condic
0 siblings, 0 replies; 11+ messages in thread
From: Marin David Condic @ 2002-03-11 15:33 UTC (permalink / raw)
This sounds like a beginner program or student project, so a database is
likely to be way overkill. If Jim could clarify where he's at
developmentally and what sort of constraints he has, it might suggest an
appropriate answer. Class project? Its probably worth talking to the prof to
get more detailed guidance in that case. He's the guy who would know what he
expects...
MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas www.pacemicro.com
Enabling the digital revolution
e-Mail: marin.condic@pacemicro.com
Web: http://www.mcondic.com/
<rmoldskr@online.no> wrote in message
news:27Ii8.7333$eJ6.134443@news2.ulv.nextra.no...
>
> Another alternative is to use an external database, and perform SQL
> calls upon that. Depending on the application, this might be the perfect
> solution, or it might be overkill.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How would i keep 'records' in ADA ?
2002-03-10 0:33 ` Jim
` (2 preceding siblings ...)
2002-03-10 12:14 ` rmoldskr
@ 2002-03-10 12:45 ` chris.danx
2002-03-11 15:39 ` Marin David Condic
3 siblings, 1 reply; 11+ messages in thread
From: chris.danx @ 2002-03-10 12:45 UTC (permalink / raw)
"Jim" <genx54321@hotmail.com> wrote in message
news:a6e9ko$b6a$1@knossos.btinternet.com...
> sorry if i was a little vague.
>
> say i was creating a database type program eg mail order company - which
> holds information such as records of customers :- name, address, tel no.
>
> i will have a menu like this
>
> MENU
>
> a. Add customer details.
> b. Delete customer details.
>
> -----------------
>
> i will have to use arrays and records right ? adding customer details is
> easy. but deleting, im not sure about. Do i just replace record for that
> customer with null statements / space character / junk (anything that gets
> rid of the details) or would i have to actually get rid of that element in
> the array ?
For simplicity use arrays (your just learning, right? So why overcomplicate
things with linked lists, SQL etc? That's just silly).
Do as T(?) Moran suggested and have some kind of unreasonable name (a name
with '-' at the beginning would be funny peculiar so it's a good choice) to
check for. If it's that name then that record is deleted, or not in use.
use a function like
function is_empty (x : in my_record) return boolean is
begin
...
end is_empty;
that will check for this condition.
If you need to save records to a file, you can just walk the array and write
the non-empty items to the file (the type of file depends on the
specification, but a text file is easy to begin with). Reading them from a
file is easier.
HTH,
Chris
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How would i keep 'records' in ADA ?
2002-03-10 12:45 ` chris.danx
@ 2002-03-11 15:39 ` Marin David Condic
0 siblings, 0 replies; 11+ messages in thread
From: Marin David Condic @ 2002-03-11 15:39 UTC (permalink / raw)
Its also important to ask if it is necessary to maintain the data in some
kind of sorted order. A random set of customer records in no particular
order would make the suggested technique of marking unused space - or
linking together unused space attractive. (Simple and efficient). If the
requirement is to be able to list everything in order (alphabetical on
customer last name?) then the problem is somewhat different & this technique
becomes less useful.
If the project is not a class project (wherein you can utilize someone
else's code and not be doing something wrong) then its probably easier to
make use of one of the many data structure packages available that would
provide a linked list. If this is the case, we can probably point you at a
few dozen prepackaged solutions...
MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas www.pacemicro.com
Enabling the digital revolution
e-Mail: marin.condic@pacemicro.com
Web: http://www.mcondic.com/
"chris.danx" <chris.danx@ntlworld.com> wrote in message
news:yyIi8.12364$xO2.961959@news11-gui.server.ntli.net...
>
> For simplicity use arrays (your just learning, right? So why
overcomplicate
> things with linked lists, SQL etc? That's just silly).
>
> Do as T(?) Moran suggested and have some kind of unreasonable name (a name
> with '-' at the beginning would be funny peculiar so it's a good choice)
to
> check for. If it's that name then that record is deleted, or not in use.
>
> use a function like
>
> function is_empty (x : in my_record) return boolean is
> begin
> ...
> end is_empty;
>
> that will check for this condition.
>
> If you need to save records to a file, you can just walk the array and
write
> the non-empty items to the file (the type of file depends on the
> specification, but a text file is easy to begin with). Reading them from
a
> file is easier.
>
>
> HTH,
> Chris
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread