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 


Select Multiple List Items...

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


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

PostPosted: Mon Aug 05, 2002 5:20 pm    Post subject: Select Multiple List Items... Reply with quote

Probably not that great for end users, but might
be handy in your own programs. Click one item,
then another...
Code:

rem -- VDS3 and VDS4 compatible --
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test prog,-1,0,300,200
  DIALOG ADD,BUTTON,B1,5,5,100,20,"Show Selection"
  DIALOG ADD,LIST,L1,30,5,290,145,,CLICK
  DIALOG ADD,STATUS,Stat,"Ready..."
DIALOG SHOW

%x = 0
REPEAT
  LIST ADD, L1, "Item number "%x
  %x = @succ(%x)
UNTIL @greater(%x, 20)

:EVLOOP
  DIALOG SET, Stat, Selected items: %%start - %%end
  WAIT EVENT
  goto @event()

:L1CLICK
  rem -- If already have start and end pos, get new start --
  if @both(%%start, %%end)
     %%start = @index(L1)
     %%end = ""
     goto EVLOOP
  end
  rem -- Get start pos first --
  if @not(%%start)
     %%start = @index(L1)
  else
     %%end = @index(L1)
  end
  goto EVLOOP

:B1BUTTON
  %s = ""
  if @both(%%start, %%end)
     if @greater(%%start,%%end)
        %y = %%start
        %x = %%end
     else
        %x = %%start
        %y = %%end
     end
     REPEAT
       %s = %s@cr()@item(L1, %x)
       %x = @succ(%x)
     UNTIL @greater(%x, %y)@not(%y)
  else
     if %%start
        %s = @cr()@item(L1, %%start)
     else
        %s = @cr()"Nothing selected..."
     end
  end
  INFO Selected items: @tab()@cr()%s
  goto EVLOOP

:CLOSE
  EXIT


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


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

PostPosted: Tue Aug 27, 2002 2:34 pm    Post subject: Reply with quote

There is oneother way, which is good to use for End-users. The code is a little longer, but who minds???

Code:

rem -- VDS3 and VDS4 compitable --
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac & Skit 3000
DIALOG CREATE,Test prog,-1,0,300,200
  DIALOG ADD,BUTTON,B1,5,5,100,20,"Show Selection"
  DIALOG ADD,LIST,L1,30,5,290,145,,CLICK
  DIALOG ADD,STATUS,Stat,"Ready..."
DIALOG SHOW

%x = 0
REPEAT
  LIST ADD, L1, "Item number "%x
  %x = @succ(%x)
UNTIL @greater(%x, 20)

:EVLOOP
dialog set,Stat,Selected Items: %%selected
wait event
goto @event()

:L1CLICK
if @equal(@substr(@item(L1),@diff(@len(@item(L1)),10),@len(@item(L1)))," - Selected")
  %z = @index(L1)
  list put,L1,@substr(@item(L1),1,@diff(@len(@item(L1)),11))
  list seek,L1,%z
  %%selected = @strdel(%%selected,@pos(" "%z" ",%%selected),@fadd(@pos(" "%z" ",%%selected),@succ(@len(%z))))
  if @equal(%%selected,)
    %%selected = -1
   end
  else
  if @equal(%%selected,-1)
    %%selected =
   end
  %z = @index(L1)
  list put,L1,@item(L1)" - Selected"
  list seek,L1,%z
  %%selected = %%selected" "%z" "
  end
goto evloop

:B1BUTTON
info Selected item(s):@cr()%%selected
goto evloop

:CLOSE
exit


EDIT1: Replaced the VDS tag by the CODE one...
EDIT2: Solved a few little bugs...


Last edited by Skit3000 on Sat Dec 07, 2002 9:15 pm; edited 2 times in total
Back to top
View user's profile Send private message
Skit3000
Admin Team


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

PostPosted: Tue Aug 27, 2002 3:55 pm    Post subject: Reply with quote

You can also use, with some small changes, FreezingFire's example.
The only negative thing of his code is that you can't make the list scroll down, because the Checkboxes must move then.

Here it is:

Code:

  DIALOG CREATE,CheckList Dialog,-1,0,265,171
  DIALOG ADD,LIST,LIST1,2,2,260,166,CLICK
  list add,list1,"     "CheckList Item 1
  DIALOG ADD,CHECK,CHECK1,4,4,14,14
  list add,list1,"     "CheckList Item 2
  DIALOG ADD,CHECK,CHECK2,18,4,14,14
  DIALOG SHOW
  :evloop
  wait event
  goto @event()
 
  :list1click
  %%index = @succ(@index(LIST1))
  if @dlgtext(check%%index)
    dialog set,check%%index,
   else
    dialog set,check%%index,1
   end
  goto evloop
 
  :close
  if @dlgtext(check1)
  warn CHECK1 was checked
  end
  if @dlgtext(check2)
  warn CHECK2 was checked
  end
  exit
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