forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


List Reverse sorted ? is possible ?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Cipper
Newbie


Joined: 21 Jun 2001
Posts: 22
Location: Trieste Italy

PostPosted: Wed Mar 26, 2003 8:30 am    Post subject: List Reverse sorted ? is possible ? Reply with quote

In VDS 3.5 I can create a reverse list sorted ?


thank you for help. Shocked
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Wed Mar 26, 2003 8:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Mar 26, 2003 8:51 am    Post subject: Reply with quote

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
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Mar 26, 2003 8:15 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Mar 26, 2003 8:17 pm    Post subject: Reply with quote

Oops. Does VDS 3 have a LIST REVERSE? Confused
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Mar 26, 2003 8:35 pm    Post subject: Reply with quote

No LIST REVERSE in VDS3, but here's how I'd do it... Wink
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 Smile

_________________
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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Mar 27, 2003 11:34 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group