⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subst.n

📁 tcl是工具命令语言
💻 N
字号:
'\"'\" Copyright (c) 1994 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\" Copyright (c) 2001 Donal K. Fellows'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: subst.n,v 1.5 2002/04/18 16:31:40 dgp Exp $'\" .so man.macros.TH subst n 7.4 Tcl "Tcl Built-In Commands".BS'\" Note:  do not modify the .SH NAME line immediately below!.SH NAMEsubst \- Perform backslash, command, and variable substitutions.SH SYNOPSIS\fBsubst \fR?\fB\-nobackslashes\fR? ?\fB\-nocommands\fR? ?\fB\-novariables\fR? \fIstring\fR.BE.SH DESCRIPTION.PPThis command performs variable substitutions, command substitutions,and backslash substitutions on its \fIstring\fR argument andreturns the fully-substituted result.The substitutions are performed in exactly the same way as forTcl commands.As a result, the \fIstring\fR argument is actually substituted twice,once by the Tcl parser in the usual fashion for Tcl commands, andagain by the \fIsubst\fR command..PPIf any of the \fB\-nobackslashes\fR, \fB\-nocommands\fR, or\fB\-novariables\fR are specified, then the corresponding substitutionsare not performed.For example, if \fB\-nocommands\fR is specified, command substitutionis not performed:  open and close brackets are treated as ordinary characterswith no special interpretation..PP.VS 8.4Note that the substitution of one kind can include substitution of other kinds.  For example, even when the \fB-novariables\fR optionis specified, command substitution is performed without restriction.This means that any variable substitution necessary to complete thecommand substitution will still take place.  Likewise, any commandsubstitution necessary to complete a variable substitution willtake place, even when \fB-nocommands\fR is specified.  See theEXAMPLES below..PPIf an error occurs during substitution, then \fBsubst\fR will returnthat error.  If a break exception occurs during command or variablesubstitution, the result of the whole substitution will be thestring (as substituted) up to the start of the substitution thatraised the exception.  If a continue exception occurs during theevaluation of a command or variable substitution, an empty stringwill be substituted for that entire command or variable substitution(as long as it is well-formed Tcl.)  If a return exception occurs,or any other return code is returned during command or variablesubstitution, then the returned value is substituted for thatsubstitution.  See the EXAMPLES below.  In this way, all exceptionalreturn codes are ``caught'' by \fBsubst\fR.  The \fBsubst\fR commanditself will either return an error, or will complete successfully..VE.SH EXAMPLES.PPWhen it performs its substitutions, \fIsubst\fR does not give anyspecial treatment to double quotes or curly braces (except withincommand substitutions) so the script.CS\fBset a 44subst {xyz {$a}}\fR.CEreturns ``\fBxyz {44}\fR'', not ``\fBxyz {$a}\fR''.VS 8.4and the script.CS\fBset a "p\\} q \\{r"subst {xyz {$a}}\fR.CEreturn ``\fBxyz {p} q {r}\fR'', not ``\fBxyz {p\\} q \\{r}\fR''..PPWhen command substitution is performed, it includes any variablesubstitution necessary to evaluate the script.  .CS\fBset a 44subst -novariables {$a [format $a]}\fR.CEreturns ``\fB$a 44\fR'', not ``\fB$a $a\fR''.  Similarly, whenvariable substitution is performed, it includes any commandsubstitution necessary to retrieve the value of the variable..CS\fBproc b {} {return c}array set a {c c [b] tricky}subst -nocommands {[b] $a([b])}\fR.CEreturns ``\fB[b] c\fR'', not ``\fB[b] tricky\fR''..PPThe continue and break exceptions allow command substitutions toprevent substitution of the rest of the command substitution and therest of \fIstring\fR respectively, giving script authors more optionswhen processing text using \fIsubst\fR.  For example, the script.CS\fBsubst {abc,[break],def}\fR.CEreturns ``\fBabc,\fR'', not ``\fBabc,,def\fR'' and the script.CS\fBsubst {abc,[continue;expr 1+2],def}\fR.CEreturns ``\fBabc,,def\fR'', not ``\fBabc,3,def\fR''..PPOther exceptional return codes substitute the returned value.CS\fBsubst {abc,[return foo;expr 1+2],def}\fR.CEreturns ``\fBabc,foo,def\fR'', not ``\fBabc,3,def\fR'' and.CS\fBsubst {abc,[return -code 10 foo;expr 1+2],def}\fR.CEalso returns ``\fBabc,foo,def\fR'', not ``\fBabc,3,def\fR''..VE.SH "SEE ALSO"Tcl(n), eval(n), break(n), continue(n).SH KEYWORDSbackslash substitution, command substitution, variable substitution

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -