egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

delimiter or split :P

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Fri Jan 02, 2009 10:26 am    Post subject: delimiter or split :P Reply with quote

hello.. i have one variable $nicks and inside i set some nicks like "nick1 nick2 nick3 nick4 nick5" is it possible to split the variable and set the nick1 like $nick1 = nick1 (from previus variable after split) $nick2 = nick2 ... up to nick5 just want to split the 1st variable to 5 like nicks..


thanks
Back to top
View user's profile Send private message
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Fri Jan 02, 2009 11:03 am    Post subject: Reply with quote

Code:
set nicks "nick1 nick2 nick3 nick4 nick5"

#use this if there could be more than 5 nicks in $nicks
for {set i 0} {$i < 6} {incr i} {
   set nick[expr $i + 1] [lindex [split $nicks] $i]
}

#or you could use this if it conatins max 5 nicks
foreach {nick1 nick2 nick3 nick4 nick5} [split $nicks ]  {}

_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Fri Jan 02, 2009 11:42 am    Post subject: Reply with quote

thnx a lot i am going to try it
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Jan 02, 2009 9:16 pm    Post subject: Reply with quote

foreach item [split $nicks] {
set nick[expr {[lsearch [split $nicks] $item] + 1}] $item
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber