I attempted to fix the line numbers not aligning properly with the code, depending on operating system + browser combination. While doing that, I also wanted to try out a new font for the code (which should work in all modern browsers, the 0 has a little dot in the middle to distinguish it from the O). Feedback is welcome!

# Returns a human readable representation of the "size" argument, which is in bytes
# the second argument specifies the number of digits after the . you want to have
prochumanify{size {digits 2}}{foreach prefix {B kiB MiB GiB TiB PiB}{set new [expr{$size/1024.0}]if{$new < 1}{break}set size $new}return"[format %.*f $digits $size] $prefix"}

The warning is actually generated by pretty simple code (not even close to what would be required to do that perfectly) and shouldn't even be there anymore, we just disabled it after you report. (the automatic syntaxchecker is way more accurate and replaces the need for that). However, the same bit of code is responsible for colorizing pairs or {} and [] and thanks to your bugreport we fixed that.

The closing ] in the regular expression is now the same as the one before (it used to be black).

I rarely touch that code, I haven't made any changes to that for almost two years (I just properly generated that patchfile, so I can update nagelfar but still keep my changes). I'll try to remember to change the paste above and post here that I updated it. (So having this thread on your watchlist should do). It's not worth putting that into a CMS

I'm currently developing a patch for eggdrop to see through ircu's +D (delayed joins) which currently has the following features:

- trigger bind join/bind nick/bind part for invisible users (checks list every minute)
- provide the tcl command "getchanlogin nick ?channel?" which returns the login (AC Token, Q/X-Auth) for the user (0 if not logged in. "" if not yet known). cached for all users on the bots channels
- provide the tcl command "isloggedin nick ?channel?" returning 1 if the user is authed, 0 if not or not found
- provide the tcl command "getchanrealname nick ?channel?" returning the realname of a user (or "" if unknown/user not found)
- provide the tcl command "isinvisible nick ?channel?" returns 1 if the user is invisible on the channel (or any channel if unspecified), 0 otherwise.

When a user joins being invisible I know the login and realname instantly, so..

First of all you should be aware that 2 common cases fit the statement "expression".Case 1: expr (the obvious one)

1

procmultiply{a b}{return[expr $a * $b]}

Case 2: If-condition. If-conditions are evaluated similar to "expr". That's the reason you can use mathematic expressions (1 + $var < 5) in the if-condition:

1

if{$a * $b == 10}{puts"Ok"}

When you learned the Tcl syntax, you usually place these braces around "$a*$b==10" in the if condition just because it's the thing you've read in the manual and other languages aren't as simple as Tcl syntaxwise. So in other language you usually just learn the if-syntax by heart.
Maybe you already found out, that you can drop them. The statement:

1

if{[string is integer $a]}{ .. }

apparently does the same as

1

if[string is integer $a]{ .. }

but it doesn't.

Now let's get to the reason you most like want to use if {..} and expr {..}.
Why {} around the statement? What's the difference?

In Tcl, {} group words like "" do, but they prevent substitution of variables, command and backslash-expressions. Compare set a "hello $var" and set a {hello $var} for example. The latter will return "hello $var" but in the first one $var will be replaced by its content. Read more in the Tcl syntax definition (Rule 4,6)

This takes time and causes the statement to get double-evaluated.
Now we apply that logic to expr:

1

set a 4; set b 2; puts[expr $a*$b] ---> "8"

1

set a 4; set b 2; puts[expr{$a*$b}] ---> "8".. note: it does NOT return"$a*$b" but "8"!

But why? Because expr evaluates its argument(s)!
expr replaces variables by its values ($var)
expr replaces commands by its values ([command])
expr replaces substitutions by its values (\n or x84)
just like enclosing an argument in double quotes would.

As I already mentioned above, this takes time. expr {$a * $b} is faster, because with expr $a * $b, the interpreter replaces $a and $b by their values, passes "2 * 4" to expr, and expr then evaluates this. Expr can do that faster if it doesn't attempt to substitute variables/commands/... another time.

But there's a much more severe problem than the evaluation time... (which usually doesn't matter that much in network applications anyway)

or similar, as the $::botnick variable is not known on startup (only on connect). And it can change which will not result in an automatic unbind and re-bind.
So we bind on * (everything) and check if the first word is our nick. Then we use switch (looks better) to determine the commands.

# Returns a random line out of $file (error if it doesnt exist)
procrandline{file}{set fs [open $file r]set data [read $fs]
close $fs# Now we have the complete content of $file stored in $data
set data [split $data \n]# Now it's a list of lines, and we use eggdrop's "rand" function to get a random element from it (and return it)
return[lindex $data[rand [llength $data]]]}