From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,afc5f41f146b8270 X-Google-Attributes: gid103376,public From: "Marin D. Condic" Subject: Re: Loading an array from a text file.... Date: 2000/03/19 Message-ID: <38D4F62F.33B68793@quadruscorp.com>#1/1 X-Deja-AN: 599500518 Content-Transfer-Encoding: 7bit References: <8b0kre$p9j$1@neptunium.btinternet.com> Organization: Quadrus Corporation X-Sender: "Marin D. Condic" (Unverified) X-Server-Date: 19 Mar 2000 12:46:33 GMT Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-19T12:46:33+00:00 List-Id: 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. =============================================================