by
skipton >> Thu, 18 Jul 2002 17:39:20 GMT
2340: How to change the sequence of reading DB class ?
Hi there,
I have to admit that I'm still not completely sure what is you are asking for help on, in future please try and use clearer examples/wording of what you are trying to achieve so we can respond accordingly.
This sounds like you are reading via something like “Maths.instances”. Most developers find it more useful to declare a root object and define a collection of Maths instances on this class which can then be ordered in whatever way you like?
I'll use a slightly different example, hopefully this is similar to what you are asking for. Consider a set of data which mirrors the layout of a book. A book is broken down into chapters, and then to paragraphs within each chapter. Our Entities(classes) here are Book, Chapter and Paragraph.
For a relationship between these classes, we will define two collections. We can put a ChapterDict (a MemberKeyDictionary with a key of chapterNumber) on Book, and on Chapter we will put a ParagraphArray (to hold the paragraphs for each chapter).
I want to change the sequence of reading
OK, does this mean:
1) you want to display the paragraphs (say in a listbox) in a different order? If you want to read through the paragraphs backwards (reversing your sequence?), there are a number of ways if achieving this
// by looping backwards through the collection
foreach para in chap reversed do
write para.text;
endforeach;
// using iterator.back(para)
// by using the listBox.listCollection showHow property
( refer to the Online Help for this)
2) you want to change the order of the paragraphs for good (persistently) - in the example Ive used this could be as the Books Editor goes through and reorders the paragraphs
For this you need to write a method to update/reorder the paragraphs to reflect the changes. Note that with MemberKeyDictionary’s you can reorder them by changing the “Ascending/Descending” properties as you declare the keys, maybe this is what you are meaning?
Hope this helps.
John Beaufoy