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.

else if { Possible?

Old posts that have not been replied to for several years.
Locked
m
minotaur
Voice
Posts: 19
Joined: Sun Jul 06, 2003 8:36 pm

else if { Possible?

Post by minotaur »

I would like to know how can is use in TCL such like that:

if { $nick == "bla" } {
putlog "Nick is bla"
}
else if { $nick == "blaa" } {
putlog "Nick is blaa"
} else {
putlog "I dont know that Nickname"
}

that doesnt work I need the else if function but how it works :( the Bot always says
Tcl error [test]: invalid command name "else"
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

Your else if is wrong. Try:

Code: Select all

if { $nick == "bla" } {
  putlog "Nick is bla"
} elseif { $nick == "blaa" } {
  putlog "Nick is blaa"
} else {
  putlog "I dont know that Nickname"
}
k
kyotou

Post by kyotou »

Not only that, but you can't put "else" or "elseif" in a new line by themselves, you must place the closing bracet before.

Code: Select all

if {a} { puts a }
else { puts b }
will result in an error
while:

Code: Select all

if {a} {
  puts a
} else {
  puts b
}
will work.
Locked