comp.lang.ada
 help / color / mirror / Atom feed
* Loading an array from a text file....
@ 2000-03-18  0:00 Matt
  2000-03-19  0:00 ` Marin D. Condic
  0 siblings, 1 reply; 2+ messages in thread
From: Matt @ 2000-03-18  0:00 UTC (permalink / raw)


Yo.
Having a bit of trouble with Ada at the moment. I am trying to write a
database for a university coursework kinda-thingy, but have hit a brick
wall!
The idea is thus: When my program first runs, it loads from a text file a
list of students, the courses & units they are on, results etc and stores
the strings into an array of records.
However, during my program, the text file will be changed (For example, if
another student is added or results are changed) and I will want to re-load
the array from the 'new' txt file. I can't do this as a function, becasue i
don't want any result, I just want it to perform a few lines of code. I
could really just re-write the code at various points in the program, but i
don't want the main program to be too 'busy' - bearing in mind this has to
be moderated!
Any feedback appreciated.
Regards,
Matt






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Loading an array from a text file....
  2000-03-18  0:00 Loading an array from a text file Matt
@ 2000-03-19  0:00 ` Marin D. Condic
  0 siblings, 0 replies; 2+ messages in thread
From: Marin D. Condic @ 2000-03-19  0:00 UTC (permalink / raw)


Matt wrote:
> 
> Yo.
> Having a bit of trouble with Ada at the moment. I am trying to write a
> database for a university coursework kinda-thingy, but have hit a brick
> wall!
> The idea is thus: When my program first runs, it loads from a text file a
> list of students, the courses & units they are on, results etc and stores
> the strings into an array of records.
> However, during my program, the text file will be changed (For example, if
> another student is added or results are changed) and I will want to re-load
> the array from the 'new' txt file. I can't do this as a function, becasue i
> don't want any result, I just want it to perform a few lines of code. I
> could really just re-write the code at various points in the program, but i
> don't want the main program to be too 'busy' - bearing in mind this has to
> be moderated!
> Any feedback appreciated.

If I am understanding your problem description correctly, it sounds to
me like you just need to have a procedure which loads the table from a
file. A spec for such a procedure might look like this:

procedure Load_The_Table (
    File_Name    : in     String ;
    Table        :    out Some_Fancy_Array_Definition) ;

Inside the procedure, you open the specified file, do a "while not
end_of_file" loop to read everything into the array, then close the
file. This would be called when your program starts up or whenever you
felt the spirit move you to re-read the database.

A good design strategy (which may be getting ahead of your class) would
be to figure out what are all the operations you need to perform on your
little database (load, store, get element, put element, etc.) and define
the data structure and associated operations within a single package.
This is often called a "container object" and has many advantages. It
provides encapsulation of all the related data/operations. It hides
information that other parts of your code do not need to know about (and
hence, they can't mess it up). It supports software reuse in that many
different applications which may need the database don't need to
redevelop the same code. Extensibility is improved in that if you ever
change something about the database or add new features, you only need
to go to a single location to make the updates. Yada Yada Yada. (I talk
too much before my first cup of coffee! :-)

Anyway, I hope this sends you off in the right direction,

MDC
-- 
=============================================================
Marin David Condic   - Quadrus Corporation -   1.800.555.3393
1015-116 Atlantic Boulevard, Atlantic Beach, FL 32233
http://www.quadruscorp.com/
m c o n d i c @ q u a d r u s c o r p . c o m

***PLEASE REMOVE THE "-NOSPAM" PART OF MY RETURN ADDRESS***

Visit my web site at:  http://www.mcondic.com/

"Because that's where they keep the money."
    --  Willie Sutton when asked why he robbed banks. 
=============================================================




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-03-19  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-18  0:00 Loading an array from a text file Matt
2000-03-19  0:00 ` Marin D. Condic

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