| View previous topic :: View next topic |
| Author |
Message |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Fri May 05, 2006 7:07 am Post subject: Need help in displaying muliple info in dcc |
|
|
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: |
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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 05, 2006 9:57 am Post subject: |
|
|
It displays one person at a time. If it's displaying only 1 person, that means there's only 1 person. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Fri May 05, 2006 10:57 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 1:35 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 05, 2006 7:08 pm Post subject: |
|
|
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:
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 7:20 pm Post subject: |
|
|
| 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:
|
This is what it looks like on my bots:
| Code: | | Tcl: {dragnlord Tarn telnet@* 0 {} 0} {bloodwind Tarn telnet@* 0 {} 0} |
multiple users, one line |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 05, 2006 7:36 pm Post subject: |
|
|
| Quote: | | {dragnlord Tarn telnet@* 0 {} 0} {bloodwind Tarn telnet@* 0 {} 0} |
is a list of 2 elements:
| Code: | # 1:
dragnlord Tarn telnet@* 0 {} 0
# 2:
bloodwind Tarn telnet@* 0 {} 0 |
Try it:
| Code: | | .tcl foreach bla [whom *] { putlog $bla } |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 8:08 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 8:17 pm Post subject: |
|
|
| Code: | | .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 |
|
| Back to top |
|
 |
spock Master
Joined: 12 Dec 2002 Posts: 319
|
Posted: Fri May 05, 2006 9:51 pm Post subject: |
|
|
| DragnLord wrote: | | Code: | | .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? |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 10:08 pm Post subject: |
|
|
then the answer someone should have given for this topic is:
replace
| Code: | | putidx $idx [format "%-1s %-10s %-20s %-36s %-1s" $w_nick $w_bot $w_host $w_idle $w_away] |
with
| Code: | | putlog [format "%-1s %-10s %-20s %-36s %-1s" $w_nick $w_bot $w_host $w_idle $w_away] |
|
|
| Back to top |
|
 |
spock Master
Joined: 12 Dec 2002 Posts: 319
|
Posted: Fri May 05, 2006 10:10 pm Post subject: |
|
|
not really. putidx works fine if you have the correct idx, and honeybee should be getting the correct one from the dcc bind _________________ photon? |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Fri May 05, 2006 10:13 pm Post subject: |
|
|
| true, adding a routine to gather the correct idx with hand2idx would work |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Fri May 05, 2006 11:35 pm Post subject: |
|
|
thou i am using | Code: | | proc dcc:help {hand idx} { | but somehow it was'nt getting the right idx. |
|
| Back to top |
|
 |
|