'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH Tcl 7tcl "8.1" Tcl "Tcl Built-In Commands" .BS .SH NAME Tcl \- 語言語法總結. .BE .SH 描述 DESCRIPTION .PP 下面的規則定義 Tcl 語言的語法和語義: .IP [1] 一個 Tcl 指令碼是一個包含一個或多個命令的字串。除了象後面描述的那樣被引用(quote)之外,分號(Semi-colon)和換行(newline)是命令分隔符。除了被引用(quote)之外,右方括號(Close bracket)在命令替換期間是命令終結符(見後)。 .IP [2] 命令的求值分兩步。 首先,Tcl 直譯器把命令分解成字 (\fIwords\fR) 並按下面描述的那樣完成替換。對所有命令都以同樣的方式進行替換。第一個字用於定位完成這個命令的一個命令過程,接著命令的所有的字被傳遞給命令過程。命令過程以它喜歡的任何方式自由的解釋命令的字,如一個整數、變數名、列表、或 Tcl 指令碼。不同的命令以不同的方式解釋它們的字。 .IP [3] 一個命令的字(word)由白空格(不包括作為命令分隔符的換行)來分隔。 .IP [4] 如果一個字的第一個字元是雙引號 (``"'',double-quote) 則字終結於下一個雙引號字元。如果是分號,右方括號,或白空格字元(包括換行)出現在引號之間則被作為普通的字元對待幷包含在字裡。象下面描述的那樣,在引號之間的字元上進行命令替換、變數替換、和反斜槓替換。雙引號不作為字的一部分而保留。 .IP [5] 如果一個字的第一個字元是左花括號 (“{”,open brace) 則字終結於相匹配的右花括號 (“}”,close brace)。花括號在字中巢狀: 對於每個增加的(additional)左花括號都必須有一個增加的右花括號(但是,如果 在一個字中的左括號或右括號被用一個反斜槓引用起來則在匹配右花括號時不計在內)。除了下面描述的反斜槓-換行替換之外,在花括號之間的字元上不進行替換,對分號、換行、右方括號、或白空格不做特殊的解釋。字由外側的花括號之間的字元精確的組成,不包括花括號自身。 .IP [6] 如果一個字包含一個左方括號 (\[lq][\[rq],open bracket ) 則 Tcl 進行命令替 換 (\fIcommand substitution\fR)。為此將遞迴呼叫 Tcl 直譯器來把左方括號後 面的字元作為一個 Tcl 指令碼處理。指令碼可以包含任意數目的命令並且必須用一個 右方括號 (\[lq]]\[rq],close bracket) 來終結。指令碼的結果(例如,最後的一條命令的結 果)將被替換到字中方括號和它們中間所有字元的位置上。在一個單一的字中可以 有任意數目的命令替換。在由花括號包起來(enclose)的字上不進行命令替換。 .IP [7] 如果一個字包含一個美元符(``$'')則 Tcl 進行變數替換 (\fIvariable substitution\fR): 字中的美元符號和跟隨的字元被一個變數的值所替換。接受下面幾種形式(form)的變數替換: .RS .TP 15 \fB$\fIname\fR \fIName\fR 是一個標量(scalar)變數的名字;名字終結於任何不是字母、數字、或下劃線(underscore)的字元。 .TP 15 \fB$\fIname\fB(\fIindex\fB)\fR \fIName\fR 給出一個數組變數的名字,\fIindex\fR 給出在這個陣列中的一個元素的名字. \fIName\fR 只能包含字母、數字、和下劃線。\fIindex\fR 的字元將被進行命令替換、變數替換、和反斜槓替換。 .TP 15 \fB${\fIname\fB}\fR \fIName\fR 是一個標量( scalar)變數的名字。它可以包含除了右括號之外的任何字元。 .LP 一個單一的字中可以有任意數目的變數替換。在由花括號包起來(enclose)的字上不進行命令替換。 .RE .IP [8] 如果在一個字中出現一個反斜槓(\[lq]\\\[rq])則發生反斜槓替換 (\fIbackslash substitution\fR)。除了下面描述的這些情況之外,反斜槓 (backslash)被刪除 (drop),跟隨的字元被作為普通字元對待。這就允許在字中包含象雙引號、右方括 號、和美元符號等字元而不觸發特殊的處理。下表列出的要特殊處理的反斜槓序列 ,跟著的是每個序列被替換成的值。 .RS .TP 7 \e\fBa\fR 聲音警告 (振鈴) (0x7). .TP 7 \e\fBb\fR 退格 (0x8). .TP 7 \e\fBf\fR 換頁 (0xc). .TP 7 \e\fBn\fR 換行 (0xa). .TP 7 \e\fBr\fR 回車 (0xd). .TP 7 \e\fBt\fR 跳格(Tab) (0x9). .TP 7 \e\fBv\fR 縱向跳格 (0xb). .TP 7 \e\fB\fIwhiteSpace\fR . 一個單一的空格字元替換反斜槓、換行和在換行後面的所有空格和跳格。這個反斜槓序列是唯一一個在命令被實際分析之前在一次獨立的預處理(pre- pass)中被替換的。這意味著即使在花括號之間這個替換也發生,並且不在花括號和引號之間時作為結果的空格被作為一個字分隔符對待。 .TP 7 \e\e 反斜槓 (``\''). .VS 8.1 br .TP 7 \e\fIooo\fR . 數字\fIooo\fR(它們中的一個、兩個、或三個)給出一個八進位制數,是要插入的 Unicode 字元的八位值。 Unicode 字元的高位(upper)將是 0. .TP 7 \e\fBx\fIhh\fR . 十六進位制數 \fIhh\fR 給出要插入的 Unicode 字元的八位值。可以提供任意數目的十六進位制數字 ;但除了最後兩位之外都被忽略(結果總是一個一位元組的數量)。Unicode 字元的高位(upper)將是 0. .TP 7 \e\fBu\fIhhhh\fR . 十六進位制數 \fIhhhh\fR (它們中的一個、兩個、三個、或四個)給出要插入的 Unicode 字元的十六位值。 .VE .LP 除了前面描述的反斜槓-換行,在由花括號包起來(enclose)的字上不進行反斜槓替換。 .RE .IP [9] 如果一個升音符 “#” (sharp / hash) 出現在 Tcl 希望是一個命令的第一個字的地方(point),則升音符和其後面跟隨的、一直到下一個換行的所有字元,被作為一個註釋對待並被忽略。註釋字元只有出現在一個命令開始時才有意義(significance)。 .IP [10] 每個字元作為建立的一個命令的某個字的一部分,被 Tcl 直譯器精確的處理一次。例如,如果發生了變數替換則在變數的值上不進行進一步的替換;值被原封不動的(verbatim)插入字中。如果發生了命令替換則巢狀的命令被對 Tcl 直譯器的遞迴呼叫整個的處理;在做遞迴呼叫之前不進行替換並且對巢狀的指令碼的結果不進行額外的(additional)替換。 .IP [11] 替換不影響一個命令的字邊界(boundary)。例如,即使變數的值包含空格,在變數替換期間變數的整個的值成為一個單一的字的一部分。 .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/06/21 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR