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.
Elfriede
Halfop
Posts: 67 Joined: Tue Aug 07, 2007 4:21 am
Post
by Elfriede » Mon May 31, 2010 7:33 am
Hey guys
i have a mysql query which gives me eg as result:
{Tom 2} {Simon 67} {Phoenix 8} {Sally 12} {Richard 43}
how can i manipulate this list to look like
Tom: 2 Simon: 67 Phoenix: 8 ... ?
many thanks
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon May 31, 2010 7:51 am
Suppose $mylist is the list containing your data (I assume it's a list of lists). You can do the following:
Code: Select all
set output ""
foreach element $mylist {
# $element is a list containing {"Name" "Score"}
foreach {a b} $element {break}
append output "${a}: $b "
}
# now $output is a string containing the data in your desired form
Elfriede
Halfop
Posts: 67 Joined: Tue Aug 07, 2007 4:21 am
Post
by Elfriede » Mon May 31, 2010 8:07 am
many thanks !