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.
Help for those learning Tcl or writing their own scripts.
honeybee
Halfop
Posts: 80 Joined: Sun Jan 01, 2006 12:42 pm
Post
by honeybee » Fri May 05, 2006 7:07 am
I'm writting a tcl in which i need to get these data and display it, its works fine but it only displays only one user instead of all. how can display multiple rather than one?
Code: Select all
foreach person [whom *] {
set w_nick [lindex $person 0]; set w_bot [lindex $person 1]; set w_host [lindex $person 2]; set w_idle [lindex $person 4]; set w_away [lindex $person 5]
Last edited by
honeybee on Wed May 10, 2006 12:20 pm, edited 1 time in total.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri May 05, 2006 9:57 am
It displays one person at a time. If it's displaying only 1 person, that means there's only 1 person.
honeybee
Halfop
Posts: 80 Joined: Sun Jan 01, 2006 12:42 pm
Post
by honeybee » Fri May 05, 2006 10:57 am
This is suppose to display one person i want a mean to display all, thats what i wanted to ask.
Last edited by
honeybee on Wed May 10, 2006 12:21 pm, edited 1 time in total.
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 1:35 pm
It only shows one person because '.tcl whom *' spits it all out in a single line.
Your proc only matches the first set, hence why you only see one reported.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri May 05, 2006 7:08 pm
Actually no, [whom *] returns a list of all users in partyline and not a string. So your script, honeybee, will display info about all connected users - each on a line. For example:
Code: Select all
opposing Shrider telnet@x.x.x.x 0
opposing Shrider telnet@x.x.x.x 0
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 7:20 pm
Sir_Fz wrote: Actually no, [whom *] returns a list of all users in partyline and not a string. So your script, honeybee, will display info about all connected users - each on a line. For example:
Code: Select all
opposing Shrider telnet@x.x.x.x 0
opposing Shrider telnet@x.x.x.x 0
This is what it looks like on my bots:
Code: Select all
Tcl: {dragnlord Tarn telnet@* 0 {} 0} {bloodwind Tarn telnet@* 0 {} 0}
multiple users, one line
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri May 05, 2006 7:36 pm
{dragnlord Tarn telnet@* 0 {} 0} {bloodwind Tarn telnet@* 0 {} 0}
is a list of 2 elements:
Code: Select all
# 1:
dragnlord Tarn telnet@* 0 {} 0
# 2:
bloodwind Tarn telnet@* 0 {} 0
Try it:
Code: Select all
.tcl foreach bla [whom *] { putlog $bla }
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 8:08 pm
You are saying that you used honeybee's code and the bot returned two lines using putidx, not putlog?
The lindex is only operating on first record.
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 8:17 pm
Code: Select all
.tcl foreach person [whom *] {return $person}
only returned a single record with 4 users logged in
returned records for all users
I'm thinking that foreach isn't the best way to split the records
spock
Master
Posts: 319 Joined: Thu Dec 12, 2002 8:40 pm
Post
by spock » Fri May 05, 2006 9:51 pm
DragnLord wrote: Code: Select all
.tcl foreach person [whom *] {return $person}
only returned a single record with 4 users logged in
returned records for all users
I'm thinking that foreach isn't the best way to split the records
you should try what fz did (putlog).
return is doing what it's supposed to, so you dont get to complete the loop
foreach works fine
edit: honeybee's code works fine here btw
photon?
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 10:08 pm
then the answer someone should have given for this topic is:
replace
Code: Select all
putidx $idx [format "%-1s %-10s %-20s %-36s %-1s" $w_nick $w_bot $w_host $w_idle $w_away]
with
Code: Select all
putlog [format "%-1s %-10s %-20s %-36s %-1s" $w_nick $w_bot $w_host $w_idle $w_away]
spock
Master
Posts: 319 Joined: Thu Dec 12, 2002 8:40 pm
Post
by spock » Fri May 05, 2006 10:10 pm
not really. putidx works fine if you have the correct idx, and honeybee should be getting the correct one from the dcc bind
photon?
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Fri May 05, 2006 10:13 pm
true, adding a routine to gather the correct idx with hand2idx would work
honeybee
Halfop
Posts: 80 Joined: Sun Jan 01, 2006 12:42 pm
Post
by honeybee » Fri May 05, 2006 11:35 pm
thou i am using
but somehow it was'nt getting the right idx.