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.

more than one arg

Old posts that have not been replied to for several years.
Locked
D
Darky

more than one arg

Post by Darky »

Hi all

I'm beginning tcl scripting, so I have quite a lot of questions .. But today I have just one :)
I have a trigger in my script that calls a bash script
However I need 2 args for my bash script, and I just find out how to grab one, exemple here :

Code: Select all

proc pub:distance { nick uhost hand chan arg } {
if {[llength $arg]==0} {
                putserv "PRIVMSG $chan :Give 2 planets !"
} else {
                catch {string trim [exec /home/darky/scripts/planet $arg $arg2 ]} distance
                putserv "privmsg $chan :$distance\r"
        }
        return 0
}
The proc is called like this
!d ARG-1 ARG-2

Thanks for your help !
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

$arg contains the entire string passed to the proc.

Note, try feeding your script somthing like "!d test {test"

Note the error.

Your working with strings, but treating them like lists.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

proc pub:distance { nick uhost hand chan arg } { 
if {[llength $arg] >= 2} { 
  catch {string trim [exec /home/darky/scripts/planet [lindex [split $arg] 0] [lindex [split $arg] 1]]} distance 
  putserv "privmsg $chan :$distance\r"
} else { 
  putserv "PRIVMSG $chan :Give 2 planets !"
}
notice the "lindex" 0 for first arg and 1 for second arg. (unless you're using pubm or msgm bind)
Locked