| View previous topic :: View next topic |
| Author |
Message |
Keen Voice
Joined: 28 Jan 2009 Posts: 10
|
Posted: Wed Jan 28, 2009 7:55 pm Post subject: syntax error in expression |
|
|
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 |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jan 28, 2009 8:00 pm Post subject: Re: syntax error in expression |
|
|
| Code: | | if {$wnick!="Jesus"} { |
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  _________________ speechles' eggdrop tcl archive
Last edited by speechles on Wed Jan 28, 2009 8:20 pm; edited 2 times in total |
|
| Back to top |
|
 |
Keen Voice
Joined: 28 Jan 2009 Posts: 10
|
Posted: Wed Jan 28, 2009 8:07 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Keen Voice
Joined: 28 Jan 2009 Posts: 10
|
Posted: Wed Jan 28, 2009 8:09 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jan 28, 2009 8:18 pm Post subject: |
|
|
| Code: | 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."
}
} |
_________________ speechles' eggdrop tcl archive
Last edited by speechles on Wed Jan 28, 2009 8:21 pm; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jan 28, 2009 8:21 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Keen Voice
Joined: 28 Jan 2009 Posts: 10
|
Posted: Wed Jan 28, 2009 8:38 pm Post subject: |
|
|
İ think i understand. an command and its component must be in the same line ?
not
}
else {
| Code: | if ..... {
} else {
} |
is there an Editor for progrraming tcl/eggdtop script? that automatically do this for me ? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jan 28, 2009 9:06 pm Post subject: |
|
|
| Keen wrote: | İ think i understand. an command and its component must be in the same line ?
not
}
else {
| Code: | if ..... {
} 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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Keen Voice
Joined: 28 Jan 2009 Posts: 10
|
Posted: Wed Jan 28, 2009 9:12 pm Post subject: |
|
|
| Thanx nml375 ii will try to use it. have i nice day |
|
| Back to top |
|
 |
|