* Simple Student Problem Ada83 @ 1997-04-19 0:00 mrbunny [not found] ` <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda> 0 siblings, 1 reply; 3+ messages in thread From: mrbunny @ 1997-04-19 0:00 UTC (permalink / raw) I have started a computer programming course at Thames Valley University in Slough, UK. where we are using Ada 83 for an introduction to programming. I have a simple problem but cannot find an answer in my course notes or text books! How do I delete a record from an array? The set up for the array is as follows; TYPE item_rec IS RE CORD ref_num : refnum_type; descrip : descrip_type; value : integer; hirer : name_type; END RECORD; TYPE item_array IS ARRAY(integer RANGE <> ) OF item rec; -- declare data variable to hold stock data max_size : CONSTANT integer := 20; stock : item_array(l..max_size); num_items : integer; -- Instantiation of array_file to hold stock items data PACKAGE item_file IS NEW array_file(item_rec, item_array, "stock.dat"); Can anyone advise of a simple solution? Thanks for your help. Mark. ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda>]
* Re: Simple Student Problem Ada83 [not found] ` <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda> @ 1997-04-20 0:00 ` Nick Roberts 1997-04-21 0:00 ` Robert Dewar 0 siblings, 1 reply; 3+ messages in thread From: Nick Roberts @ 1997-04-20 0:00 UTC (permalink / raw) Bob Klungle <grbg@junque.com> wrote in article <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda>... > Several possibilities come to mind without thinking much. No elegance, just > hack. [hackish solution] Alternatively, (a) suppose the array is called A (b) suppose the number of valid components in A at any particular time is in n (c) suppose the component of A to be deleted is number i a slightly less hackish solution might go along these lines: (1) check that i is not greater than n (what should we do if it is?) (2) copy the components from A(i+1..n) into A(i..n-1) (3) decrement n I will leave coding this into Ada as an exercise, since this is supposed to be an exercise for you! Answer the question posed at the end of (1) - it is an important question. Also, answer the following question. The copy in (2) will be implemented by Ada as a loop, copying the machine elements, let's say bytes, of the array slice specified. This loop will have two 'byte pointers' addressing the byte to be copied from and the byte to be copied to. There are two possible schemes: (1) both pointers are set at their respective last bytes to be copied, and both are decremented; (2) both pointers are set to their respective first bytes and both incremented. Which scheme - (1) or (2) - will be used in this particular example, and why? Nick. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Simple Student Problem Ada83 1997-04-20 0:00 ` Nick Roberts @ 1997-04-21 0:00 ` Robert Dewar 0 siblings, 0 replies; 3+ messages in thread From: Robert Dewar @ 1997-04-21 0:00 UTC (permalink / raw) iNick Roberts said <<I will leave coding this into Ada as an exercise, since this is supposed to be an exercise for you! Answer the question posed at the end of (1) - it is an important question.>> Nope, the excercise was to *figure out how* to do the coding. When you give someone this much of a roadmap, you have entirely undrmined an assignment. The coding is entirely secondary. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-04-21 0:00 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-04-19 0:00 Simple Student Problem Ada83 mrbunny [not found] ` <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda> 1997-04-20 0:00 ` Nick Roberts 1997-04-21 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox