Page 1 of 1
SectionList; change order
Posted: Mon Feb 19, 2007 11:58 am
by thats_karlo
Hi,
Do you have any idea how we can change the position of section in a SectionList.
suppose in forsec seclist1 {print secname()} gives this results
dend[10]
dend[9]
dend[4]
dend[3]
dend[1]
i like to have a new section list which give me this result,
forsec new_seclist1{print secname()}
dend[1]
dend[3]
dend[4]
dend[9]
dend[10]
Posted: Tue Feb 20, 2007 5:55 pm
by thats_karlo
HI!
There is no way for that!!!
this is why i didn't get any answer?
Reversing the sequence of sections in a SectionList
Posted: Wed Feb 21, 2007 7:15 am
by ted
The trick is to build an intermediate List of SectionRefs, then read backwards through that List.
Code: Select all
objref sr, templist
forsec oldseclist templist.append(new SectionRef())
// templist now contains SectionRefs in the same order as the sections in oldseclist
objref newseclist
newseclist = SectionList()
for (i=templist.count()-1; i>0; i=i-1) {
templist.object(i).sec newseclist.append()
}
objref templist // destroy the List of SectionRefs, which is no longer needed
// newseclist has the same sections as oldseclist, but in reverse order
Posted: Wed Feb 21, 2007 9:27 am
by thats_karlo
Hi Ted,
Wonderful!!! thank you so much
Posted: Sun Apr 15, 2007 2:03 pm
by JimH
Here are some of the code lines I modified, as well as an added explanation at the bottom which helped me understand better what was going on
Code: Select all
newseclist = new SectionList() //I got an error without "new" on MSwindows
Code: Select all
//Without "=" in ">=" one section was being dropped
for (i=templist.count()-1; i>=0; i=i-1) {
Unfortunately the SectionList does properties/functions (please excuse the loose terminology) like count or object, so instead the sectionList is put into a List (not a SectionList), and then back into a sectionList.