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.

change line output

Help for those learning Tcl or writing their own scripts.
Post Reply
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

change line output

Post by Elfriede »

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

Post by Sir_Fz »

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
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

many thanks ! :)
Post Reply