📄 tcl.n
字号:
'\"'\" 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.'\" '\" SCCS: @(#) Tcl.n 1.128 96/08/26 12:59:50'.so man.macros.TH Tcl n "" Tcl "Tcl Built-In Commands".BS.SH NAMETcl \- Summary of Tcl language syntax..BE.SH DESCRIPTION.PPThe following rules define the syntax and semantics of the Tcl language:.IP [1]A Tcl script is a string containing one or more commands.Semi-colons and newlines are command separators unless quoted asdescribed below.Close brackets are command terminators during command substitution(see below) unless quoted..IP [2]A command is evaluated in two steps.First, the Tcl interpreter breaks the command into \fIwords\fRand performs substitutions as described below.These substitutions are performed in the same way for allcommands.The first word is used to locate a command procedure tocarry out the command, then all of the words of the command arepassed to the command procedure.The command procedure is free to interpret each of its wordsin any way it likes, such as an integer, variable name, list,or Tcl script.Different commands interpret their words differently..IP [3]Words of a command are separated by white space (except fornewlines, which are command separators)..IP [4]If the first character of a word is double-quote (``"'') thenthe word is terminated by the next double-quote character.If semi-colons, close brackets, or white space characters(including newlines) appear between the quotes then they are treatedas ordinary characters and included in the word.Command substitution, variable substitution, and backslash substitutionare performed on the characters between the quotes as described below.The double-quotes are not retained as part of the word..IP [5]If the first character of a word is an open brace (``{'') thenthe word is terminated by the matching close brace (``}'').Braces nest within the word: for each additional openbrace there must be an additional close brace (however,if an open brace or close brace within the word isquoted with a backslash then it is not counted in locating thematching close brace).No substitutions are performed on the characters between thebraces except for backslash-newline substitutions describedbelow, nor do semi-colons, newlines, close brackets,or white space receive any special interpretation.The word will consist of exactly the characters between theouter braces, not including the braces themselves..IP [6]If a word contains an open bracket (``['') then Tcl performs\fIcommand substitution\fR.To do this it invokes the Tcl interpreter recursively to processthe characters following the open bracket as a Tcl script.The script may contain any number of commands and must be terminatedby a close bracket (``]'').The result of the script (i.e. the result of its last command) issubstituted into the word in place of the brackets and all of thecharacters between them.There may be any number of command substitutions in a single word.Command substitution is not performed on words enclosed in braces..IP [7]If a word contains a dollar-sign (``$'') then Tcl performs \fIvariablesubstitution\fR: the dollar-sign and the following characters arereplaced in the word by the value of a variable.Variable substitution may take any of the following forms:.RS.TP 15\fB$\fIname\fR\fIName\fR is the name of a scalar variable; the name is terminatedby any character that isn't a letter, digit, or underscore..TP 15\fB$\fIname\fB(\fIindex\fB)\fR\fIName\fR gives the name of an array variable and \fIindex\fR givesthe name of an element within that array.\fIName\fR must contain only letters, digits, and underscores.Command substitutions, variable substitutions, and backslashsubstitutions are performed on the characters of \fIindex\fR..TP 15\fB${\fIname\fB}\fR\fIName\fR is the name of a scalar variable. It may contain anycharacters whatsoever except for close braces..LPThere may be any number of variable substitutions in a single word.Variable substitution is not performed on words enclosed in braces..RE.IP [8]If a backslash (``\e'') appears within a word then\fIbackslash substitution\fR occurs.In all cases but those described below the backslash is dropped andthe following character is treated as an ordinarycharacter and included in the word.This allows characters such as double quotes, close brackets,and dollar signs to be included in words without triggeringspecial processing.The following table lists the backslash sequences that arehandled specially, along with the value that replaces each sequence..RS.TP 6\e\fBa\fRAudible alert (bell) (0x7)..TP 6\e\fBb\fRBackspace (0x8)..TP 6\e\fBf\fRForm feed (0xc)..TP 6\e\fBn\fRNewline (0xa)..TP 6\e\fBr\fRCarriage-return (0xd)..TP 6\e\fBt\fRTab (0x9)..TP 6\e\fBv\fRVertical tab (0xb)..TP 6\e\fB<newline>\fIwhiteSpace\fRA single space character replaces the backslash, newline, and allspaces and tabs after the newline.This backslash sequence is unique in that it is replaced in a separatepre-pass before the command is actually parsed.This means that it will be replaced even when it occurs betweenbraces, and the resulting space will be treated as a word separatorif it isn't in braces or quotes..TP 6\e\eBackslash (``\e'')..TP 6\e\fIooo\fRThe digits \fIooo\fR (one, two, or three of them) give the octal value ofthe character..TP 6\e\fBx\fIhh\fRThe hexadecimal digits \fIhh\fR give the hexadecimal value ofthe character. Any number of digits may be present..LPBackslash substitution is not performed on words enclosed in braces,except for backslash-newline as described above..RE.IP [9]If a hash character (``#'') appears at a point where Tcl isexpecting the first character of the first word of a command,then the hash character and the characters that follow it, upthrough the next newline, are treated as a comment and ignored.The comment character only has significance when it appearsat the beginning of a command..IP [10]Each character is processed exactly once by the Tcl interpreteras part of creating the words of a command.For example, if variable substitution occurs then no furthersubstitutions are performed on the value of the variable; thevalue is inserted into the word verbatim.If command substitution occurs then the nested command isprocessed entirely by the recursive call to the Tcl interpreter;no substitutions are performed before making the recursivecall and no additional substitutions are performed on the resultof the nested script..IP [11]Substitutions do not affect the word boundaries of a command.For example, during variable substitution the entire value ofthe variable becomes part of a single word, even if the variable'svalue contains spaces.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -