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 Setpos

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


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

PostPosted: Fri Nov 01, 2002 9:59 pm    Post subject: List Setpos Reply with quote

Hi all,

I was wondering why there isn't any function in VDS to set a List item to another index number, so I made a little subroutine for it...

I think it can be improved, but it works fine for now...

Code:
list create,1
list add,1,0
list add,1,3
list add,1,2
list add,1,1
list add,1,4
list add,1,5

rem        |list|index1|index2
%%setpos = 1   |3     |1
gosub List_setpos
info @text(1)

%%setpos = 1|2|3
gosub List_setpos
info @text(1)
exit



:List_setpos
parse "%%listnumber;%%index1;%%index2",%%setpos
%%indexnumber = @index(%%listnumber)
list seek,%%listnumber,%%index1
%%indextext = @item(%%listnumber)
list delete,%%listnumber
if @not(@greater(@succ(%%index2),@count(%%listnumber)))
  list seek,%%listnumber,%%index2
  list insert,%%listnumber
  list put,%%listnumber,%%indextext
  else
  list add,%%listnumber,%%indextext
  end
list seek,%%listnumber,%%indexnumber
exit


EDIT1: Replaced the VDS tag for the CODE tag.


Last edited by Skit3000 on Sat Nov 30, 2002 1:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Sat Nov 30, 2002 12:38 pm    Post subject: Re: List Setpos Reply with quote

this can be done much easier:

Code:
list create,1
list add,1,3
list add,1,1
list add,1,4
list add,1,5
list add,1,2

list seek,1,1
%1 = @item(1)
list seek,1,4
%2 = @item(1)
list seek,1,0
%3 = @item(1)
list seek,1,2
%4 = @item(1)
list seek,1,3
%5 = @item(1)

list seek,1,0
list put,1,%1
list seek,1,1
list put,1,%2
list seek,1,2
list put,1,%3
list seek,1,3
list put,1,%4
list seek,1,4
list put,1,%5


well, I think this is easier, but it's still a little difficult Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Skit3000
Admin Team


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

PostPosted: Sat Nov 30, 2002 1:19 pm    Post subject: Reply with quote

You way is easier indeed, but if you have large lists, you must have a lot of code. I try always to make subroutines so that you'll only need two simple lines of code to do something...
Back to top
View user's profile Send private message
Garrett
Moderator Team


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

PostPosted: Sat Nov 30, 2002 11:51 pm    Post subject: Reply with quote

I have a few list examples on the main site for working with lists. How to move items up and down in the list etc... You might check those out to see if they can be of any help also.



[ GT-DragItemInList.dsc ]

Author: Garrett R. Hylltun
Version: 1.0
Date: September 10, 2002
Size: 8 kB
Requirements: vds 4.50 or higher

Drag an item within a list either up or down. Item is inserted into new location when mouse button is released. If mouse button is released when not over the list, then the item is put back where it started from.
http://www.vdsworld.com/vdsscript.php?url=downloads/script/GT-DragItemInList.dsc



[ GT-DragItemList2List.dsc ]

Author: Garrett R. Hylltun
Version: 1.0
Date: September 10, 2002
Size: 10 kB
Requirements: vds 4.50 or higher

Who says you can't drag and drop between list elements in VDS?? Well you can. Not multiple items at once in this example, but at least it shows you how to drag one item from one list to another and vice versa.
http://www.vdsworld.com/vdsscript.php?url=downloads/script/GT-DragItemList2List.dsc



[ GT-ListTree.dsc ] - 171 downloads [ Preview ]

Author: Garrett R. Hylltun
Date: February 8, 2002
Size: 14 kB
Requirements: vds 3.00 or higher

Using a List element as a Tree List. Use this example code to create a very simple and basic Tree List that can expand and collapse in your VDS Programs. Address Books, Mini File Explorers, Note Books, whatever comes to your mind that could use a Tree List. Note: doesn't work with VDS 4.
http://www.vdsworld.com/vdsscript.php?url=downloads/script/GT-ListTree.dsc



And last but not least, this outdated example which is still useful:

[ listexam.dsc ] - 376 downloads [ Preview ]

Author: Garrett R. Hylltun
Version: 1.0
Date: March 12, 1999
Size: 5 kB
Requirements: vds 3.00 or higher

Example of LIST manipulations for VDS 3.0, such as moving list items, deleting them, adding new items into the list.
http://www.vdsworld.com/vdsscript.php?url=downloads/script/listexam.dsc


-Garrett
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 -> Visual DialogScript 3 Source Code 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