12.5.25    list

Description:   Create a list of values separated by spaces

Syntax:         list ?arg arg ...?

         

Argument:     variable name, a list of values, commands

Returns:         text string with a list of values, with spaces between elements

See Also:       lappend, llength, lindex, lsearch, split, foreach, append, concat

 

Examples:      #example 1

set x [list {a b c d e f}] {

SETVAL text1=$x

# The value of x and tag text1 is "a b c d e f"

 

#example 2 -  display error if it occurs

if {[catch [list SCREXEC sourcein.bad] err]} {

   SETVAL "text=Failed. $err "

   }

Returns a list comprised of all the args.  An empty string if no args are specified. Braces and backslashes get added as necessary, so that the index command may be used on the result to re-extract the original arguments. 

eval may also be used to execute the resulting list, with arg1 comprising the command’s name and the other args comprising its arguments. List produces slightly different results than concat. concat removes a level of grouping.  list works directly from the original arguments.