| View previous topic :: View next topic |
| Author |
Message |
Cipper Newbie
Joined: 21 Jun 2001 Posts: 22 Location: Trieste Italy
|
Posted: Wed Mar 26, 2003 8:30 am Post subject: List Reverse sorted ? is possible ? |
|
|
In VDS 3.5 I can create a reverse list sorted ?
thank you for help.  |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Mar 26, 2003 8:46 am Post subject: |
|
|
Not directly. But you could keep your content in one sorted list and then reverse that one
in another list whenever needed.
E.g.:
| Code: |
list create,1,SORTED
list add,1,1
list add,1,5
list add,1,3
list add,1,4
list add,1,2
info @text(1)
list create,2
%%inc = 0
repeat
list insert,2,@item(1,%%inc)
%%inc = @succ(%%inc)
until @equal(@index(1),@pred(@count(1)))
info @text(2)
|
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Mar 26, 2003 8:51 am Post subject: |
|
|
Yes. Add a list element that is 0,0,0,0 in size. Add the SORTED style to
that list, and then fill that list with the data you want. Once list is filled, it
is sorted. Now to reverse the list, create a data list and do something like
this:
| Code: |
DIALOG CREATE,LIST REVERSE SORT,0,0,300,200
DIALOG ADD,LIST1,0,0,0,0,SORTED
DIALOG SHOW
LIST CREATE,1
LIST LOADFILE,LIST1,(some file)
REM or fill your list1 with data some other way.
LIST SEEK,LIST1,0
LIST ADD,1, @item(LIST1)
%A = @next(LIST1)
Repeat
LIST SEEK,1,0
LIST INSERT,1,@item(LIST1)
%A = @next(LIST1)
Until @not(@ok()) |
The data list named 1 now has your sorted list in reverse order. From
there you can either use 1 or assign it to another list element.
The above code should work, but was not tested. Only typed from
thoughts and not in the ide. Just to show you the idea.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Mar 26, 2003 8:15 pm Post subject: |
|
|
What about this:
| Code: | list create,1,SORTED
list add,1,1
list add,1,5
list add,1,3
list add,1,4
list add,1,2
info @text(1)
list reverse,1
info @text(1) |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Mar 26, 2003 8:17 pm Post subject: |
|
|
Oops. Does VDS 3 have a LIST REVERSE?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Mar 26, 2003 8:35 pm Post subject: |
|
|
No LIST REVERSE in VDS3, but here's how I'd do it...
| Code: |
LIST CREATE, 1, SORTED
LIST CREATE, 2
LIST ADD, 1, "1"
LIST ADD, 1, "2"
LIST ADD, 1, "3"
INFO @text(1)
%x = @pred(@count(1))
REPEAT
LIST ADD, 2, @item(1, %x)
%x = @pred(%x)
UNTIL @greater(0, %x)
INFO @text(2)
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Mar 27, 2003 11:34 am Post subject: |
|
|
Here is one which only uses one list...
| Code: | list create,1,sorted
list add,1,"1"
list add,1,"2"
list add,1,"3"
info @text(1)
%x = 0
repeat
%z = @item(1,%x)@cr()@chr(10)%z
%x = @succ(%x)
info %z|@item(1,%x)
until @equal(%x,@count(1))
list close,1
list create,1
list assign,1,%z
info @text(1)
list close,1 |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|