Need help in displaying muliple info in dcc

Help for those learning Tcl or writing their own scripts.
Post Reply
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Need help in displaying muliple info in dcc

Post by honeybee »

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.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

It displays one person at a time. If it's displaying only 1 person, that means there's only 1 person.
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

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.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

{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 }
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

.tcl foreach person [whom *] {return $person}
only returned a single record with 4 users logged in

Code: Select all

.tcl whom *
returned records for all users

I'm thinking that foreach isn't the best way to split the records
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

DragnLord wrote:

Code: Select all

.tcl foreach person [whom *] {return $person}
only returned a single record with 4 users logged in

Code: Select all

.tcl whom *
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?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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] 
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

not really. putidx works fine if you have the correct idx, and honeybee should be getting the correct one from the dcc bind
photon?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

true, adding a routine to gather the correct idx with hand2idx would work
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

thou i am using

Code: Select all

proc dcc:help {hand idx} {
but somehow it was'nt getting the right idx.
Post Reply