====== Getting started with Tcl: example 9 ====== This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]] ===== Lists versus strings ===== ==== Script ==== #!/usr/bin/tclsh # lits versus strings puts stdout "" set MyString "Happy New Year" set MyList [list {a b} c hello 5] # From a string to a list: split foreach item [split $MyString] { puts stdout "item = $item" } puts stdout "" # From a list to a string: join # NB: concat applies on the list obtained with split $MyString set MyString [join [concat [split $MyString] $MyList] : ] puts stdout "Now, MyString = $MyString" ==== Output ==== item = Happy item = New item = Year Now, MyString = Happy:New:Year:a b:c:hello:5
---- This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]]