This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
-
keeper2
- Voice
- Posts: 12
- Joined: Wed Jul 19, 2006 10:16 am
Post
by keeper2 »
Can somebody help me to do the following.
On a command lets say !add the user can add a value to a list.
Lets say the user type:
!add test
!add test2
Then the list should contains test;test2 seperated by a ;
If the user type again
!add test2
it should not be added to the list saying its already in.
If the user types
!del test
the value test should be deleted in the list.
-
nml375
- Revered One
- Posts: 2860
- Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 »
Have a look at the list commands in tcl: list, lappend, lsearch, lreplace
Roughly tho, something like this (not complete code):
Code: Select all
#add:
proc addlist {what} {
global mylist
if {[lsearch $mylist $what] == -1} {
lappend mylist $what
}
}
#delete:
proc dellist {what} {
global mylist
set i [lsearch $mylist $what]
set mylist [lreplace $mylist $i $i]
}
#Get "proper" layout, separate with ; instead...
proc getproper {} {
global mylist
return [join $mylist ";"]
}
Not complete code, but should give you a decent example on how to use those commands
NML_375
-
keeper2
- Voice
- Posts: 12
- Joined: Wed Jul 19, 2006 10:16 am
Post
by keeper2 »
yes I worked it out

was not so difficult as I think before your code help to find the way.