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 

switch help

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


Joined: 13 Mar 2007
Posts: 18

PostPosted: Sat Mar 17, 2007 1:23 pm    Post subject: switch help Reply with quote

im only quite new to tcl scripting, and i want to set a switch to use as variables within a proc. im not too sure how to do this properly, so if someone could just give me a quick example.

on command in channel !select, i want to use a switch to give me a variable number. so the line in a channel would be:

!select --n20 rest of the text string here

i want to use whatever number after --n as the variable to use in the rest of the proc, and i need the rest of the text string in a variable too.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Mar 17, 2007 1:48 pm    Post subject: Reply with quote

Code:
bind pub - !select pub:select

proc pub:select {nick uhost hand chan arg} {
 # --n#
 set switch [lindex [split $arg] 0]
 # if switch is not --n<number> then return
 if {![regexp -- {--n[0-9]{1,}} $switch]} {return 0}
 # take the number after --n
 set num [string range $switch 3 end]
 # take the rest
 set rest [join [lrange [split $arg] 1 end]]
 switch -- $num {
  1 {
   # the number is 1, do whatever
  }
  2 {
   # the number is 2, do whatever
  }
  default {
   # any other number
  }
 }
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
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