Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase

Model Technology Inc.


List processing

In Tcl a "list" is a set of strings in curly braces separated by spaces. Several Tcl commands are available for creating lists, indexing into lists, appending to lists, getting the length of lists and shifting lists. These commands are:

Command syntax
Description
lappend var_name val1 val2 ...
appends val1, val2, etc. to list var_name
lindex list_name index
returns the index-th element of list_name; the first element is 0
linsert list_name index val1 val2 ...
inserts val1, val2, etc. just before the index-th element of list_name
list val1, val2 ...
returns a Tcl list consisting of val1, val2, etc.
llength list_name
returns the number of elements in list_name
lrange list_name first last
returns a sublist of list_name, from index first to index last; first or last may be "end", which refers to the last element in the list
lreplace list_name first last val1, val2, ...
replaces elements first through last with val1, val2, etc.

Two other commands, lsearch and lsort, are also available for list manipulation. See the Tcl man pages (Help > Tcl Man Pages) for more information on these commands.

See also the ModelSim Tcl command: lecho


Model Technology Inc.
Model Technology Incorporated
Voice: (503) 641-1340
Fax: (503)526-5410
www.model.com
sales@model.com
Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase