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 

syntax error in expression

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


Joined: 28 Jan 2009
Posts: 10

PostPosted: Wed Jan 28, 2009 7:55 pm    Post subject: syntax error in expression Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Jan 28, 2009 8:00 pm    Post subject: Re: syntax error in expression Reply with quote

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 Razz
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Wed Jan 28, 2009 8:20 pm; edited 2 times in total
Back to top
View user's profile Send private message
Keen
Voice


Joined: 28 Jan 2009
Posts: 10

PostPosted: Wed Jan 28, 2009 8:07 pm    Post subject: Reply with quote

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 ?
Smile

im very new with tcl. jut for to days ( and im not english so sometimes i cant understand.)

Thanx
Back to top
View user's profile Send private message
Keen
Voice


Joined: 28 Jan 2009
Posts: 10

PostPosted: Wed Jan 28, 2009 8:09 pm    Post subject: Reply with quote

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"
Smile

can you correct the code for me so i can understand what i is wrong?
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Jan 28, 2009 8:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jan 28, 2009 8:21 pm    Post subject: Reply with quote

The problem at hand are these lines:
Code:
}
else {


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:
Code:
} else {

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Keen
Voice


Joined: 28 Jan 2009
Posts: 10

PostPosted: Wed Jan 28, 2009 8:38 pm    Post subject: Reply with quote

İ 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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jan 28, 2009 9:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Keen
Voice


Joined: 28 Jan 2009
Posts: 10

PostPosted: Wed Jan 28, 2009 9:12 pm    Post subject: Reply with quote

Thanx nml375 ii will try to use it. have i nice day
Back to top
View user's profile Send private message
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