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.
Old posts that have not been replied to for several years.
-
Psx|Dk
- Voice
- Posts: 11
- Joined: Thu Aug 21, 2003 9:04 am
Post
by Psx|Dk »
ì extract this from a database !
[A] 10 4 [C] 1
how do i make code so it shows up like that in chan ?
[A] 10
4
[C] 1
i know i can make
putserv "PRIVMSG $chan : [lindex $var 0] [lindex $var 1]
putserv "PRIVMSG $chan : [lindex $var 2] [lindex $var 3]
putserv "PRIVMSG $chan : [lindex $var 4] [lindex $var 5]
but the amount of [*] in the info can be from 1 to 15 mabye more
etc. [A] 12 11 [C] 10 [D] 9 [E] 8 [F] 7
and then oupput
[A] 12
11
[C] 10
[D] 9
[E] 8
[F] 7
Any there can help me make this code ?
-
CrazyCat
- Revered One
- Posts: 1359
- Joined: Sun Jan 13, 2002 8:00 pm
- Location: France
-
Contact:
Post
by CrazyCat »
split on a particular character, as "[" and then you have the couple:
A] 10
B] 4
C] 1
Now, you can split each on "]" and then you have each separates values

-
Psx|Dk
- Voice
- Posts: 11
- Joined: Thu Aug 21, 2003 9:04 am
Post
by Psx|Dk »
Well how do i get it to out put if i split em to there are no more ?
i can use a [lindex *
db output stored in $stats
set split [split $stats "\["]
if { [lindex $split 0] == "" } {
set msg ""
} else {
set msg "[lindex $split 0]"
}
but how do i get it to cuntinure to all data are used ?
-
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 x {[A] 12 [B] 11 [C] 10 [D] 9 [E] 8 [F] 7}
foreach {a b} $x {puthelp "privmsg $chan :$a $b"}
Last edited by
demond on Thu Dec 09, 2004 11:08 am, edited 1 time in total.
-
Psx|Dk
- Voice
- Posts: 11
- Joined: Thu Aug 21, 2003 9:04 am
Post
by Psx|Dk »
Ohhh
you lost me there
not alle the time there are the same values in stats !
[*] there can be one or many more
and info inside [] can be difrent to
1.
$stats = [A] 15 [C] 9
or
2.
$stats = [E] 30 [G] 11 [H] 8 [S] 1
hope you follow what im trying to tell
ohhh yeah it will always set the biggest numbre first

-
demond
- Revered One
- Posts: 3073
- Joined: Sat Jun 12, 2004 9:58 am
- Location: San Francisco, CA
-
Contact:
Post
by demond »
what's there to be lost into?
you simply lappend your data pairs to a list and then:
Code: Select all
foreach {element1 element2} $thelist {
# do something with these elements
# ...
}
-
CrazyCat
- Revered One
- Posts: 1359
- Joined: Sun Jan 13, 2002 8:00 pm
- Location: France
-
Contact:
Post
by CrazyCat »
Code: Select all
foreach {key value} $stats {
putserv "PRIVMSG $chan :$key is $value"
}
Edited: I'm too tired 2day 
-
Psx|Dk
- Voice
- Posts: 11
- Joined: Thu Aug 21, 2003 9:04 am
Post
by Psx|Dk »
CrazyCat that are almost there
looks like this now
is [A]
is 19
is [H]
is 4
is
is 1
acutaly need it like
[A] 19
[H] 4
1
-
CrazyCat
- Revered One
- Posts: 1359
- Joined: Sun Jan 13, 2002 8:00 pm
- Location: France
-
Contact:
Post
by CrazyCat »
Tested in my egg:
Code: Select all
[17:55:14] <CrazyCat> .tcl set stats "\[E\] 30 \[G\] 11 \[H\] 8 \[S\] 1"
[17:56:25] <CrazyCat> .tcl foreach {key val} $stats { putlog "$key is $val" }
[17:56:26] <Viviane> [17:55] tcl: evaluate (.tcl): foreach {key val} $stats { putlog "$key is $val" }
[17:56:26] <Viviane> [17:55] [E] is 30
[17:56:26] <Viviane> [17:55] [G] is 11
[17:56:26] <Viviane> [17:55] [H] is 8
[17:56:26] <Viviane> [17:55] [S] is 1
It works, so I can't help you more...
-
Psx|Dk
- Voice
- Posts: 11
- Joined: Thu Aug 21, 2003 9:04 am
Post
by Psx|Dk »
Didn't notice you had made a edit of your previous post !
Thanx alot for the quick and good help

-
CrazyCat
- Revered One
- Posts: 1359
- Joined: Sun Jan 13, 2002 8:00 pm
- Location: France
-
Contact:
Post
by CrazyCat »
Ok, all right
