Code: Select all
proc pub:calc {nick uh hand chan arg} {
set x 0
set z +
foreach a [split $arg] {
switch -- $a {
{*} -
{-} -
{/} -
{+} { set z $a }
default {
if {![regexp {^[0-9]+$} $a]} {
puthelp "PRIVMSG $chan :Invalid character found"
return
}
set x [expr $x $z $a]
}
}
puthelp "PRIVMSG $chan :Calculated value = $x"
}
bind pub - "!calc" pub:calc
Code: Select all
proc sexpr {e} {
if {[catch {expr 0+[list $e]} r]} {
set e "syntax error in expression \"$e\""
} {
set e "$e = $r"
}
}
Code: Select all
set x 0
set z +
Code: Select all
if {[llength [split $arg]] == 1} { set arg [join [split $arg {}]] }
Your switch is missing a }, so the putserv is in fact inside the foreach loop ....if you get the code compiled by adding a } to the end (which normal people wouldn't doppslim wrote:Can anybody else solve that one, I am finding it very hard.
Looking at my code, it is near impossible. It would require that the proc physicaly be called twice.
The puthelp line is only called once, and isn't in a loop of any kind.
!calc 10+10 = 2 if you do thatppslim wrote:Code: Select all
set x 0 set z +
Code: Select all
if {[llength [split $arg]] == 1} { set arg [join [split $arg {}]] }