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.

Problems with Brackets & Pipes...

Old posts that have not been replied to for several years.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

ProXy wrote:Okay I fixed the bug with the ban, and the script works fine now, but i still have some questions:

Code: Select all

	if {([llength $arg]==0) || (![string is digit [lindex [split $arg] 1]]) || ([llength [lindex [split $arg] 2]])} {
This line should check if: The user entered a parameter , the user entered a number, the user typed a third (wrong) argument.
A right input would be: !lamer NICK 10, but not !lamer NICK 10 BLA.
I hope you understand my thinking. Now, what should be fxied in this short source to make it work better?
Doing [llength [lindex [split $arg] 2]] just to see if there is a third element, is a bit complicated.

Why not do it like:

Code: Select all


set arglist [split $arg]
set listlen [llength $arglist]
switch -- $listlen {
   0 { # no nick, no bantime }
   1 { # no bantime }
   2 { # 2 parameters }
   default { # more than 2 parameters }
}

Of course you can else make an if-elseif-elseif-else construction without "returns"

One interesting question is: if someone types !lamer nick 10 (i.e. !lamer<space><space>nick<space>10).
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Papillon wrote:

Code: Select all

if {($arg == "") || (![string is digit [lindex [split $arg] 1]]) || ([llength [split $arg]] == "3")} {
!lamer Papillon 10000 BLA BLA BLEH

:D
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

lol :D
Elen sila lúmenn' omentielvo
Locked