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.

number of users

Help for those learning Tcl or writing their own scripts.
Post Reply
K
Koepi
Voice
Posts: 26
Joined: Sun Aug 31, 2003 1:21 am

number of users

Post by Koepi »

I count the number of users in my channel with

Code: Select all

set anzahl [expr [llength [chanlist $chan]]]
i have a txt file, user.txt. every nick in the channel who is in this file should be decrease from the number of users.

user.txt

Code: Select all

user1
user2
user3
I hope you understand what i mean and can help me.

greets Koepi
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

set count [llength [chanlist $chan]]
foreach n [split [read [open user.txt]] \n] {
   if {[onchan $n $chan]} {incr count -1}
}
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
K
Koepi
Voice
Posts: 26
Joined: Sun Aug 31, 2003 1:21 am

Post by Koepi »

thx, works fine :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The file should be closed though.

Code: Select all

set count [llength [chanlist $chan]] 
foreach n [split [read [set f [open user.txt]]] \n][close $f] { 
   if {[onchan $n $chan]} {incr count -1} 
}
K
Koepi
Voice
Posts: 26
Joined: Sun Aug 31, 2003 1:21 am

Post by Koepi »

Okay thx. Is integrated, but you explan me what does this do?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

It's the same script, but this one closes the file after reading it in order not to open too many files which will lead to errors if excess files has been opened.
K
Koepi
Voice
Posts: 26
Joined: Sun Aug 31, 2003 1:21 am

Post by Koepi »

Okay, thanks.
Post Reply