📄 x-codetcl4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Tcl Coding Conventions </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="x-codetcl.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="x-codetcl.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-codetcl3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-codetcl5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84397">A.4 Tcl Procedure Layout</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84399"> </a>The following conventions define the standard layout for every procedure in a module.</p><dd><p class="Body"><a name="84400"> </a>Each procedure is preceded by the procedure documentation, a series of Tcl comments that includes the following blocks. The documentation contains no blank lines, but each block is delimited with a line containing a single pound symbol (<b class="operator">#</b>) in the first column. </p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84401"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Banner:</b></font> A Tcl comment that consists of 78 pound symbols (<b class="operator">#</b>) across the page.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84402"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Title:</b></font> One line containing the routine name followed by a short, one-line description. The routine name in the title must match the declared routine name. This line becomes the title of automatically generated reference entries and indexes.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84403"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Description:</b></font> A full description of what the routine does and how to use it.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84752"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Synopsis:</b></font> The word <i class="term">SYNOPSIS:</i> followed by a the synopsis of the procedure--its name and parameter list between <b class="symbol_UC">.tS</b> and <b class="symbol_UC">.tE</b> macros. Optional parameters are shown in square brackets. A variable list of arguments is represented by three dots (<b>...</b>).</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84753"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Parameters:</b></font> For each parameter, the <b class="symbol_UC">.IP</b> macro followed by the parameter name on one line, followed by its complete description on the next line. Include the default value and domain of definition in each parameter description.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84406"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Returns:</b></font> The word <i class="term">RETURNS:</i> followed by a description of the possible explicit result values of the subroutine (that is, values returned with the Tcl <b class="keyword">return</b> command).</li></ul></p><dl class="margin"><dd><pre class="Code2"><b><a name="84407">RETURNS: A list of 11 items: vxTicks taskId status priority pc sp errno timeout entry priNormal name</a></b></pre></dl><dl class="margin"><dd><div class="Indent"><a name="84408"> </a>If the return value is meaningless enter N/A:</div><br></dl><dl class="margin"><dd><pre class="Code2"><b><a name="84409">RETURNS: N/A</a></b></pre></dl><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84410"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Errors:</b></font> The word <i class="term">ERRORS:</i> followed by all the error messages or error code (or both, if necessary) raised in the procedure by the Tcl <b class="keyword">error</b> command.</li></ul></p><dl class="margin"><dd><pre class="Code2"><b><a name="84411">ERRORS: "Cannot find symbol in symbol table"</a></b></pre></dl><dl class="margin"><dd><div class="Indent"><a name="84412"> </a>If no <b class="keyword">error</b> statement is invoked in the procedure, enter N/A.</div><br></dl><dl class="margin"><dd><pre class="Code2"><b><a name="84413">ERRORS: N/A</a></b></pre></dl></dl><dl class="margin"><dd><p class="Body"><a name="84414"> </a>The procedure documentation ends with an empty Tcl comment starting in column one. </p><dd><p class="Body"><a name="84415"> </a>The procedure declaration follows the procedure heading and is separated from the documentation block by a single blank line. The format of the procedure and parameter declarations is shown in <a href="x-codetcl6.html#84436"><i class="title">A.6 Declaration Formats</i></a>.</p><dd><p class="Body"><a name="84419"> </a>The following is an example of a standard procedure layout.</p></dl></dl><h4 class="EntityTitle"><a name="84420"><font face="Helvetica, sans-serif" size="-1" class="sans">Example A-3: Standard Tcl Procedure Layout</font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="84421">##################################################################### # # browse - browse an object, given its ID # # This routine is bound to the "Show" button, and is invoked when # that button is clicked. If the argument (the contents of... # # SYNOPSIS # .tS # browse [objAddr | symbol | &symbol] # .tE # # PARAMETERS # .IP <objAddr> # the address of an object to browse # .IP <symbol> # a symbolic address whose contents is the address of # an object to browse # .IP <&symbol> # a symbolic address that is the address of an object to browse # # RETURNS: N/A # # ERRORS: N/A #</a></b><dd> <b><a name="84422">proc browse {args} { ... }</a></b></pre></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="x-codetcl.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="x-codetcl.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-codetcl3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-codetcl5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -