Page 1 of 1

sort lists

Posted: 2008-01-02 22:40:15
by ABNormal
if i load a xml (with a .LoadFromFile option), is there a way to sort it for a field (country or category....)?
i saw a procedure SortList into StringUtils7552.pas file, but i haven't understood how it works and if it can be useful for my needs.
nowaday i create with a program the xml file, then i load it as database and export its datas sorting them then start a second program that use that oredered "html" file.
if it would be imaginable a sorting of records after the creation, all that operations could be done in a single program....
any ideas?

Posted: 2008-01-03 08:37:15
by antp
That procedure seems to simply sort a TStringList, so it won't be useful for multiple-field data like what you have in your XML file.
I did not include the Sort procedure in the XML procedures, though that it actually exists. For that I would have to recompile the program. But anway it is a simple sort on nodes names. In your case you would need a more advanced sort, and I am not sure that the one made int he XML component will be useable through the scripting engine (due to some limitations in it).
So maybe the only solution would be to make a manual sort like what was done in that stringutils7752 file...

Posted: 2008-01-04 11:02:56
by ABNormal
thanks Antoine....
my 3 neurons are suggesting me to organize that file putting the field-that-orders-database as first voice in each record, then try to use that function.... or doing an all-manual selection, as you suggests.

ah! other question: why, if i do this:
- for n=1 to 10000 do begin
- load a file as a variable (always the same variable)
- do few operations with it
- save it
- end

program goes Out Of Memory? is that variable not resetted every time is used? and then, how to free used memory during a great loop?

Posted: 2008-01-04 11:10:41
by antp
depends what you do exactly... it is quite possible that the script engine has some memory problems and does not empty what it used.