Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/lassign.n @ 43

Last change on this file since 43 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 1.8 KB
Line 
1'\"
2'\" Copyright (c) 1992-1999 Karl Lehenbauer & Mark Diekhans
3'\" Copyright (c) 2004 Donal K. Fellows
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: lassign.n,v 1.5 2007/12/13 15:22:32 dgp Exp $
9'\"
10.so man.macros
11.TH lassign n 8.5 Tcl "Tcl Built-In Commands"
12.BS
13'\" Note:  do not modify the .SH NAME line immediately below!
14.SH NAME
15lassign \- Assign list elements to variables
16.SH SYNOPSIS
17\fBlassign \fIlist varName \fR?\fIvarName ...\fR?
18.BE
19
20.SH DESCRIPTION
21.PP
22This command treats the value \fIlist\fR as a list and assigns
23successive elements from that list to the variables given by the
24\fIvarName\fR arguments in order.  If there are more variable names
25than list elements, the remaining variables are set to the empty
26string.  If there are more list elements than variables, a list of
27unassigned elements is returned.
28.SH EXAMPLES
29An illustration of how multiple assignment works, and what happens
30when there are either too few or too many elements.
31.CS
32lassign {a b c} x y z       ;# Empty return
33puts $x                     ;# Prints "a"
34puts $y                     ;# Prints "b"
35puts $z                     ;# Prints "c"
36
37lassign {d e} x y z         ;# Empty return
38puts $x                     ;# Prints "d"
39puts $y                     ;# Prints "e"
40puts $z                     ;# Prints ""
41
42lassign {f g h i} x y       ;# Returns "h i"
43puts $x                     ;# Prints "f"
44puts $y                     ;# Prints "g"
45.CE
46The \fBlassign\fR command has other uses.  It can be used to create
47the analogue of the
48.QW shift
49command in many shell languages like this:
50.CS
51set ::argv [lassign $::argv argumentToReadOff]
52.CE
53.SH "SEE ALSO"
54lindex(n), list(n), lset(n), set(n)
55
56.SH KEYWORDS
57assign, element, list, multiple, set, variable
Note: See TracBrowser for help on using the repository browser.