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.
Keen
Voice
Posts: 10 Joined: Wed Jan 28, 2009 7:47 pm
Post
by Keen » Wed Jan 28, 2009 7:55 pm
hello i try to if then else syntax aber i see this error on ctcp chat windows with my bot.
Tcl error [opekle]: syntax error in expression "$ahmet!=Jesus": variable references require preceding $
tcl codes are:
set wnick "Jesus"
bind pub - !opekle opekle
proc opekle {nick host hand chan text} {
global ahmet
set wnick [lindex $text 0]
if {$wnick!=Jesus} {
putserv "privmsg $chan :You are not Jesus."
}
else {
putserv "privmsg $chan :You are Jesus."
}
}
what is the problem? what is wrong please help me thanx
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Wed Jan 28, 2009 8:00 pm
Try using quotes around a literal expression perhaps? Your next error will be
invalid command name: else because for some reason you close the
if clause and put the
else on the next line... Don't complain it's case-sensitive either, you wrote it
Last edited by
speechles on Wed Jan 28, 2009 8:20 pm, edited 2 times in total.
Keen
Voice
Posts: 10 Joined: Wed Jan 28, 2009 7:47 pm
Post
by Keen » Wed Jan 28, 2009 8:07 pm
thanx a lots it is working
[01:51] <@Jesus> !opekle
[02:01] <@Jesus> !opekle
[02:01] <opLa> You are not Jesus.
[02:03] <@
jesus > !opekle
[02:03] <opLa> You are not Jesus.
İt is not case sensitive. and there is no any problem after i use quotes arround literal?
is it okey ?
im very new with tcl. jut for to days ( and im not english so sometimes i cant understand.)
Thanx
Keen
Voice
Posts: 10 Joined: Wed Jan 28, 2009 7:47 pm
Post
by Keen » Wed Jan 28, 2009 8:09 pm
Sorry you are rigt. the second error ist
02:01] <opLa> [18:01] Tcl error [opekle]: invalid command name "else"
[02:03] <opLa> [18:03] Tcl error [opekle]: invalid command name "else"
can you correct the code for me so i can understand what i is wrong?
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Wed Jan 28, 2009 8:18 pm
Code: Select all
bind pub - !opekle opekle
proc opekle {nick host hand chan text} {
if {[string equal -nocase $nick "jesus"]} {
putserv "privmsg $chan :You are Jesus."
} else {
putserv "privmsg $chan :You are not Jesus."
}
}
Last edited by
speechles on Wed Jan 28, 2009 8:21 pm, edited 1 time in total.
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Wed Jan 28, 2009 8:21 pm
The problem at hand are these lines:
In tcl, there is no command named "else". Instead, it's a parameter for
if . What you need to keep in mind here, is that tcl is newline-terminated, with the exception of newlines within a string (enclosed with either "" or {}).
Simply put, the above should be something like this:
NML_375
Keen
Voice
Posts: 10 Joined: Wed Jan 28, 2009 7:47 pm
Post
by Keen » Wed Jan 28, 2009 8:38 pm
İ think i understand. an command and its component must be in the same line ?
not
}
else {
is there an Editor for progrraming tcl/eggdtop script? that automatically do this for me ?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Wed Jan 28, 2009 9:06 pm
Keen wrote: İ think i understand. an command and its component must be in the same line ?
not
}
else {
Correct.
Keen wrote: is there an Editor for progrraming tcl/eggdtop script? that automatically do this for me ?
I can't think of any specific IDE that keeps track of newlines like that. There are, however, numerous editors/IDE's out there that do support highlighting of tcl-code, one of my favourites being emacs.
NML_375
Keen
Voice
Posts: 10 Joined: Wed Jan 28, 2009 7:47 pm
Post
by Keen » Wed Jan 28, 2009 9:12 pm
Thanx nml375 ii will try to use it. have i nice day