home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume25 / tcl / part33 < prev    next >
Encoding:
Text File  |  1991-11-15  |  44.3 KB  |  1,065 lines

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i101:  tcl - tool command language, version 6.1, Part33/33
  4. Message-ID: <1991Nov15.230149.22491@sparky.imd.sterling.com>
  5. X-Md4-Signature: 90584bdb2366a3c0051580e20599b9b1
  6. Date: Fri, 15 Nov 1991 23:01:49 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 101
  11. Archive-name: tcl/part33
  12. Environment: UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 33 (of 33)."
  21. # Contents:  tcl6.1/doc/Tcl.man.2
  22. # Wrapped by karl@one on Tue Nov 12 19:44:34 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'tcl6.1/doc/Tcl.man.2' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'tcl6.1/doc/Tcl.man.2'\"
  26. else
  27. echo shar: Extracting \"'tcl6.1/doc/Tcl.man.2'\" \(41756 characters\)
  28. sed "s/^X//" >'tcl6.1/doc/Tcl.man.2' <<'END_OF_FILE'
  29. X.PP
  30. XIf a regular expression could match two different parts of a string,
  31. Xit will match the one which begins earliest.
  32. XIf both begin in the same place but match different lengths, or match
  33. Xthe same length in different ways, life gets messier, as follows.
  34. X.PP
  35. XIn general, the possibilities in a list of branches are considered in
  36. Xleft-to-right order, the possibilities for ``*'', ``+'', and ``?'' are
  37. Xconsidered longest-first, nested constructs are considered from the
  38. Xoutermost in, and concatenated constructs are considered leftmost-first.
  39. XThe match that will be chosen is the one that uses the earliest
  40. Xpossibility in the first choice that has to be made.
  41. XIf there is more than one choice, the next will be made in the same manner
  42. X(earliest possibility) subject to the decision on the first choice.
  43. XAnd so forth.
  44. X.PP
  45. XFor example, ``(ab|a)b*c'' could match ``abc'' in one of two ways.
  46. XThe first choice is between ``ab'' and ``a''; since ``ab'' is earlier, and does
  47. Xlead to a successful overall match, it is chosen.
  48. XSince the ``b'' is already spoken for,
  49. Xthe ``b*'' must match its last possibility\(emthe empty string\(emsince
  50. Xit must respect the earlier choice.
  51. X.PP
  52. XIn the particular case where no ``|''s are present and there is only one
  53. X``*'', ``+'', or ``?'', the net effect is that the longest possible
  54. Xmatch will be chosen.
  55. XSo ``ab*'', presented with ``xabbbby'', will match ``abbbb''.
  56. XNote that if ``ab*'' is tried against ``xabyabbbz'', it
  57. Xwill match ``ab'' just after ``x'', due to the begins-earliest rule.
  58. X(In effect, the decision on where to start the match is the first choice
  59. Xto be made, hence subsequent choices must respect it even if this leads them
  60. Xto less-preferred alternatives.)
  61. X.VE
  62. X
  63. X.SH "COMMAND RESULTS"
  64. X.PP
  65. XEach command produces two results:  a code and a string.  The
  66. Xcode indicates whether the command completed successfully or not,
  67. Xand the string gives additional information.  The valid codes are
  68. Xdefined in tcl.h, and are:
  69. X.RS
  70. X.TP 20
  71. X\fBTCL_OK\fR
  72. XThis is the normal return code, and indicates that the command completed
  73. Xsuccessfully.  The string gives the command's return value.
  74. X.TP 20
  75. X\fBTCL_ERROR\fR
  76. XIndicates that an error occurred; the string gives a message describing
  77. Xthe error.
  78. X.VS
  79. XIn additon, the global variable \fBerrorInfo\fR will contain
  80. Xhuman-readable information
  81. Xdescribing which commands and procedures were being executed when the
  82. Xerror occurred, and the global variable \fBerrorCode\fR will contain
  83. Xmachine-readable details about the error, if they are available.
  84. XSee the section BUILT-IN VARIABLES below for more information.
  85. X.VE
  86. X.VE
  87. X.TP 20
  88. X\fBTCL_RETURN\fR
  89. XIndicates that the \fBreturn\fR command has been invoked, and that the
  90. Xcurrent procedure (or top-level command or \fBsource\fR command)
  91. Xshould return immediately.  The
  92. Xstring gives the return value for the procedure or command.
  93. X.TP 20
  94. X\fBTCL_BREAK\fR
  95. XIndicates that the \fBbreak\fR command has been invoked, so the
  96. Xinnermost loop should abort immediately.  The string should always
  97. Xbe empty.
  98. X.TP 20
  99. X\fBTCL_CONTINUE\fR
  100. XIndicates that the \fBcontinue\fR command has been invoked, so the
  101. Xinnermost loop should go on to the next iteration.  The string
  102. Xshould always be empty.
  103. X.RE
  104. XTcl programmers do not normally need to think about return codes,
  105. Xsince TCL_OK is almost always returned.  If anything else is returned
  106. Xby a command, then the Tcl interpreter immediately stops processing
  107. Xcommands and returns to its caller.  If there are several nested
  108. Xinvocations of the Tcl interpreter in progress, then each nested
  109. Xcommand will usually return the error to its caller, until eventually
  110. Xthe error is reported to the top-level application code.  The
  111. Xapplication will then display the error message for the user.
  112. X.PP
  113. XIn a few cases, some commands will handle certain ``error'' conditions
  114. Xthemselves and not return them upwards.  For example, the \fBfor\fR
  115. Xcommand checks for the TCL_BREAK code; if it occurs, then \fBfor\fR
  116. Xstops executing the body of the loop and returns TCL_OK to its
  117. Xcaller.  The \fBfor\fR command also handles TCL_CONTINUE codes and the
  118. Xprocedure interpreter handles TCL_RETURN codes.  The \fBcatch\fR
  119. Xcommand allows Tcl programs to catch errors and handle them without
  120. Xaborting command interpretation any further.
  121. X
  122. X.SH PROCEDURES
  123. X.PP
  124. XTcl allows you to extend the command interface by defining
  125. Xprocedures.  A Tcl procedure can be invoked just like any other Tcl
  126. Xcommand (it has a name and it receives one or more arguments).
  127. XThe only difference is that its body isn't a piece of C code linked
  128. Xinto the program; it is a string containing one or more other
  129. XTcl commands.  See the \fBproc\fR command for information on
  130. Xhow to define procedures and what happens when they are invoked.
  131. X
  132. X.SH VARIABLES \- SCALARS AND ARRAYS
  133. X.VS
  134. X.PP
  135. XTcl allows the definition of variables and the use of their values
  136. Xeither through \fB$\fR-style variable substitution, the \fBset\fR
  137. Xcommand, or a few other mechanisms.
  138. XVariables need not be declared:  a new variable will automatically
  139. Xbe created each time a new variable name is used.
  140. X.PP
  141. XTcl supports two types of variables:  scalars and arrays.
  142. XA scalar variable has a single value, whereas an array variable
  143. Xcan have any number of elements, each with a name (called
  144. Xits ``index'') and a value.
  145. XArray indexes may be arbitrary strings; they need not be numeric.
  146. XParentheses are used refer to array elements in Tcl commands.
  147. XFor example, the command
  148. X.DS C
  149. X\fBset x(first) 44\fR
  150. X.DE
  151. Xwill modify the element of \fBx\fR whose index is \fBfirst\fR
  152. Xso that its new value is \fB44\fR.
  153. XTwo-dimensional arrays can be simulated in Tcl by using indexes
  154. Xthat contain multiple concatenated values.
  155. XFor example, the commands
  156. X.DS C
  157. X\fBset a(2,3) 1\fR
  158. X\fBset a(3,6) 2\fR
  159. X.DE
  160. Xset the elements of \fBa\fR whose indexes are \fB2,3\fR and \fB3,6\fR.
  161. X.PP
  162. XIn general, array elements may be used anywhere in Tcl that scalar
  163. Xvariables may be used.
  164. XIf an array is defined with a particular name, then there may
  165. Xnot be a scalar variable with the same name.
  166. XSimilarly, if there is a scalar variable with a particular
  167. Xname then it is not possible to make array references to the
  168. Xvariable.
  169. XTo convert a scalar variable to an array or vice versa, remove
  170. Xthe existing variable with the \fBunset\fR command.
  171. X.PP
  172. XThe \fBarray\fR command provides several features for dealing
  173. Xwith arrays, such as querying the names of all the elements of
  174. Xthe array and searching through the array one element at a time.
  175. X.VE
  176. X.PP
  177. XVariables may be either global or local.  If a variable
  178. Xname is used when a procedure isn't being executed, then it
  179. Xautomatically refers to a global variable.  Variable names used
  180. Xwithin a procedure normally refer to local variables associated with that
  181. Xinvocation of the procedure.  Local variables are deleted whenever
  182. Xa procedure exits.  The \fBglobal\fR command may be used to request
  183. Xthat a name refer to a global variable for the duration of the current
  184. Xprocedure (this is somewhat analogous to \fBextern\fR in C).
  185. X
  186. X.SH "BUILT-IN COMMANDS"
  187. X.PP
  188. XThe Tcl library provides the following built-in commands, which will
  189. Xbe available in any application using Tcl.  In addition to these
  190. Xbuilt-in commands, there may be additional commands defined by each
  191. Xapplication, plus commands defined as Tcl procedures.
  192. XIn the command syntax descriptions below, words in boldface are
  193. Xliterals that you type verbatim to Tcl.
  194. XWords in italics are meta-symbols; they serve as names for any of
  195. Xa range of values that you can type.
  196. XOptional arguments or groups of arguments are indicated by enclosing them
  197. Xin question-marks.
  198. XEllipses (``...'') indicate that any number of additional
  199. Xarguments or groups of arguments may appear, in the same format
  200. Xas the preceding argument(s).
  201. X.TP
  202. X\fBappend \fIvarName value \fR?\fIvalue value ...\fR?
  203. X.VS
  204. XAppend all of the \fIvalue\fR arguments to the current value
  205. Xof variable \fIvarName\fR.  If \fIvarName\fR doesn't exist,
  206. Xit is given a value equal to the concatenation of all the
  207. X\fIvalue\fR arguments.
  208. XThis command provides an efficient way to build up long
  209. Xvariables incrementally.
  210. XFor example, ``\fBappend a $b\fR'' is much more efficient than
  211. X``\fBset a $a$b\fR'' if \fB$a\fR is long.
  212. X.VE
  213. X.TP
  214. X\fBarray \fIoption arrayName\fR ?\fIarg arg ...\fR?
  215. X.VS
  216. XThis command performs one of several operations on the
  217. Xvariable given by \fIarrayName\fR.
  218. X\fIArrayName\fR must be the name of an existing array variable.
  219. XThe \fIoption\fR argument determines what action is carried
  220. Xout by the command.
  221. XThe legal \fIoptions\fR (which may be abbreviated) are:
  222. X.RS
  223. X.TP
  224. X\fBarray anymore \fIarrayName searchId\fR
  225. XReturns 1 if there are any more elements left to be processed
  226. Xin an array search, 0 if all elements have already been
  227. Xreturned.
  228. X\fISearchId\fR indicates which search on \fIarrayName\fR to
  229. Xcheck, and must have been the return value from a previous
  230. Xinvocation of \fBarray startsearch\fR.
  231. XThis option is particularly useful if an array has an element
  232. Xwith an empty name, since the return value from
  233. X\fBarray nextelement\fR won't indicate whether the search
  234. Xhas been completed.
  235. X.TP
  236. X\fBarray donesearch \fIarrayName searchId\fR
  237. XThis command terminates an array search and destroys all the
  238. Xstate associated with that search.  \fISearchId\fR indicates
  239. Xwhich search on \fIarrayName\fR to destroy, and must have
  240. Xbeen the return value from a previous invocation of
  241. X\fBarray startsearch\fR.  Returns an empty string.
  242. X.TP
  243. X\fBarray names \fIarrayName\fR
  244. XReturns a list containing the names of all of the elements in
  245. Xthe array.
  246. XIf there are no elements in the array then an empty string is
  247. Xreturned.
  248. X.TP
  249. X\fBarray nextelement \fIarrayName searchId\fR
  250. XReturns the name of the next element in \fIarrayName\fR, or
  251. Xan empty string if all elements of \fIarrayName\fR have
  252. Xalready been returned in this search.  The \fIsearchId\fR
  253. Xargument identifies the search, and must have
  254. Xbeen the return value of an \fBarray startsearch\fR command.
  255. XWarning:  if elements are added to or deleted from the array,
  256. Xthen all searches are automatically terminated just as if
  257. X\fBarray donesearch\fR had been invoked; this will cause
  258. X\fBarray nextelement\fR operations to fail for those searches.
  259. X.TP
  260. X\fBarray size \fIarrayName\fR
  261. XReturns a decimal string giving the number of elements in the
  262. Xarray.
  263. X.TP
  264. X\fBarray startsearch \fIarrayName\fR
  265. XThis command initializes an element-by-element search through the
  266. Xarray given by \fIarrayName\fR, such that invocations of the
  267. X\fBarray nextelement\fR command will return the names of the
  268. Xindividual elements in the array.
  269. XWhen the search has been completed, the \fBarray donesearch\fR
  270. Xcommand should be invoked.
  271. XThe return value is a
  272. Xsearch identifier that must be used in \fBarray nextelement\fR
  273. Xand \fBarray donesearch\fR commands; it allows multiple
  274. Xsearches to be underway simultaneously for the same array.
  275. X.VE
  276. X.RE
  277. X.TP
  278. X\fBbreak\fR
  279. XThis command may be invoked only inside the body of a loop command
  280. Xsuch as \fBfor\fR or \fBforeach\fR or \fBwhile\fR.  It returns a TCL_BREAK code
  281. Xto signal the innermost containing loop command to return immediately.
  282. X.TP
  283. X\fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...?
  284. X.TP
  285. X\fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?}
  286. XMatch \fIstring\fR against each of the \fIpatList\fR arguments
  287. Xin order.  If one matches, then evaluate the following \fIbody\fR argument
  288. Xby passing it recursively to the Tcl interpreter, and return the result
  289. Xof that evaluation.  Each \fIpatList\fR argument consists of a single
  290. Xpattern or list of patterns.  Each pattern may contain any of the wild-cards
  291. Xdescribed under \fBstring match\fR.  If a \fIpatList\fR
  292. Xargument is \fBdefault\fR, the corresponding body will be evaluated
  293. Xif no \fIpatList\fR matches \fIstring\fR.  If no \fIpatList\fR argument
  294. Xmatches \fIstring\fR and no default is given, then the \fBcase\fR
  295. Xcommand returns an empty string.
  296. X.RS
  297. X.PP
  298. XTwo syntaxes are provided.
  299. XThe first uses a separate argument for each of the patterns and commands;
  300. Xthis form is convenient if substitutions are desired on some of the
  301. Xpatterns or commands.
  302. X.VS
  303. XThe second form places all of the patterns and commands together into
  304. Xa single argument; the argument must have proper list structure, with
  305. Xthe elements of the list being the patterns and commands.
  306. XThe second form makes it easy to construct multi-line case commands,
  307. Xsince the braces around the whole list make it unnecessary to include a
  308. Xbackslash at the end of each line.
  309. XSince the \fIpatList\fR arguments are in braces in the second form,
  310. Xno command or variable substitutions are performed on them;  this makes
  311. Xthe behavior of the second form different than the first form in some
  312. Xcases.
  313. X.PP
  314. XBelow are some examples of \fBcase\fR commands:
  315. X.DS
  316. X\fBcase abc in {a b} {format 1} default {format 2} a* {format 3}
  317. X.DE
  318. Xwill return \fB3\fR, 
  319. X.DS
  320. X.ta .5c 1c
  321. X\fBcase a in {
  322. X    {a b} {format 1}
  323. X    default {format 2}
  324. X    a* {format 3}
  325. X}
  326. X.DE
  327. Xwill return \fB1\fR, and
  328. X.DS
  329. X.ta .5c 1c
  330. X\fBcase xyz {
  331. X    {a b}
  332. X        {format 1}
  333. X    default
  334. X        {format 2}
  335. X    a*
  336. X        {format 3}
  337. X}
  338. X.DE
  339. Xwill return \fB2\fR.
  340. X.VE
  341. X.RE
  342. X.TP
  343. X\fBcatch\fI command \fR?\fIvarName\fR?
  344. XThe \fBcatch\fR command may be used to prevent errors from aborting
  345. Xcommand interpretation.  \fBCatch\fR calls the Tcl interpreter recursively
  346. Xto execute \fIcommand\fR, and always returns a TCL_OK code, regardless of
  347. Xany errors that might occur while executing \fIcommand\fR.  The return
  348. Xvalue from \fBcatch\fR is a decimal string giving the
  349. Xcode returned by the Tcl interpreter after executing \fIcommand\fR.
  350. XThis will be \fB0\fR (TCL_OK) if there were no errors in \fIcommand\fR; otherwise
  351. Xit will have a non-zero value corresponding to one of the exceptional
  352. Xreturn codes (see tcl.h for the definitions of code values).  If the
  353. X\fIvarName\fR argument is given, then it gives the name of a variable;
  354. X\fBcatch\fR will set the value of the variable to the string returned
  355. Xfrom \fIcommand\fR (either a result or an error message).
  356. X.TP
  357. X\fBcd \fR?\fIdirName\fR?
  358. X.VS
  359. XChange the current working directory to \fIdirName\fR, or to the
  360. Xhome directory (as specified in the HOME environment variable) if
  361. X\fIdirName\fR is not given.
  362. XIf \fIdirName\fR starts with a tilde, then tilde-expansion is
  363. Xdone as described for \fBTcl_TildeSubst\fR.
  364. XReturns an empty string.
  365. XThis command can potentially be disruptive to an application,
  366. Xso it may be removed in some applications.
  367. X.TP
  368. X\fBclose \fIfileId\fR
  369. XCloses the file given by \fIfileId\fR.
  370. X\fIFileId\fR must be the return value from a previous invocation
  371. Xof the \fBopen\fR command; after this command, it should not be
  372. Xused anymore.
  373. XIf \fIfileId\fR refers to a command pipeline instead of a file,
  374. Xthen \fBclose\fR waits for the children to complete.
  375. XThe normal result of this command is an empty string, but errors
  376. Xare returned if there are problems in closing the file or waiting
  377. Xfor children to complete.
  378. X.VE
  379. X.TP
  380. X\fBconcat\fI arg \fR?\fIarg ...\fR?
  381. XThis command treats each argument as a list and concatenates them
  382. Xinto a single list.  It permits any number of arguments.  For example,
  383. Xthe command
  384. X.RS
  385. X.DS
  386. X\fBconcat a b {c d e} {f {g h}}\fR
  387. X.DE
  388. Xwill return
  389. X.DS
  390. X\fBa b c d e f {g h}\fR
  391. X.DE
  392. Xas its result.
  393. X.RE
  394. X.TP
  395. X\fBcontinue\fR
  396. XThis command may be invoked only inside the body of a loop command
  397. Xsuch as \fBfor\fR or \fBforeach\fR or \fBwhile\fR.  It
  398. Xreturns a  TCL_CONTINUE code
  399. Xto signal the innermost containing loop command to skip the
  400. Xremainder of the loop's body
  401. Xbut continue with the next iteration of the loop.
  402. X.TP
  403. X\fBeof \fIfileId\fR
  404. X.VS
  405. XReturns 1 if an end-of-file condition has occurred on \fIfileId\fR,
  406. X0 otherwise.
  407. X\fIFileId\fR must have been the return
  408. Xvalue from a previous call to \fBopen\fR, or it may be \fBstdin\fR,
  409. X\fBstdout\fR, or \fBstderr\fR to refer to one of the standard I/O
  410. Xchannels.
  411. X.VE
  412. X.TP
  413. X\fBerror \fImessage\fR ?\fIinfo\fR? ?\fIcode\fR?
  414. XReturns a TCL_ERROR code, which causes command interpretation to be
  415. Xunwound.  \fIMessage\fR is a string that is returned to the application
  416. Xto indicate what went wrong.
  417. X.RS
  418. X.PP
  419. XIf the \fIinfo\fR argument is provided and is non-empty,
  420. Xit is used to initialize the global variable \fBerrorInfo\fR.
  421. X\fBerrorInfo\fR is used to accumulate a stack trace of what
  422. Xwas in progress when an error occurred; as nested commands unwind,
  423. Xthe Tcl interpreter adds information to \fBerrorInfo\fR.  If the
  424. X\fIinfo\fR argument is present, it is used to initialize
  425. X\fBerrorInfo\fR and the first increment of unwind information
  426. Xwill not be added by the Tcl interpreter.  In other
  427. Xwords, the command containing the \fBerror\fR command will not appear
  428. Xin \fBerrorInfo\fR; in its place will be \fIinfo\fR.
  429. XThis feature is most useful in conjunction with the \fBcatch\fR command:
  430. Xif a caught error cannot be handled successfully, \fIinfo\fR can be used
  431. Xto return a stack trace reflecting the original point of occurrence
  432. Xof the error:
  433. X.DS
  434. X\fBcatch {...} errMsg
  435. Xset savedInfo $errorInfo
  436. X\&...
  437. Xerror $errMsg $savedInfo\fR
  438. X.DE
  439. X.PP
  440. X.VS
  441. XIf the \fIcode\fR argument is present, then its value is stored
  442. Xin the \fBerrorCode\fR global variable.  This variable is intended
  443. Xto hold a machine-readable description of the error in cases where
  444. Xsuch information is available; see the section BUILT-IN VARIABLES
  445. Xbelow for information on the proper format for the variable.
  446. XIf the \fIcode\fR argument is not
  447. Xpresent, then \fBerrorCode\fR is automatically reset to
  448. X``NONE'' by the Tcl interpreter as part of processing the
  449. Xerror generated by the command.
  450. X.VE
  451. X.RE
  452. X.TP
  453. X\fBeval \fIarg \fR?\fIarg ...\fR?
  454. X\fBEval\fR takes one or more arguments, which together comprise a Tcl
  455. Xcommand (or collection of Tcl commands separated by newlines in the
  456. Xusual way).  \fBEval\fR concatenates all its arguments in the same
  457. Xfashion as the \fBconcat\fR command, passes the concatenated string to the
  458. XTcl interpreter recursively, and returns the result of that
  459. Xevaluation (or any error generated by it).
  460. X.TP
  461. X\fBexec \fIarg \fR?\fIarg ...\fR?
  462. X.VS
  463. XThis command treats its arguments as the specification
  464. Xof one or more UNIX commands to execute as subprocesses.
  465. XThe commands take the form of a standard shell pipeline;
  466. X``|'' arguments separate commands in the
  467. Xpipeline and cause standard output of the preceding command
  468. Xto be piped into standard input of the next command.
  469. X.RS
  470. X.PP
  471. XUnder normal conditions the result of the \fBexec\fR command
  472. Xconsists of the standard output produced by the last command
  473. Xin the pipeline.
  474. XIf any of the commands in the pipeline exit abnormally or
  475. Xare killed or suspended, then \fBexec\fR will return an error
  476. Xand the error message will include the pipeline's output followed by
  477. Xerror messages describing the abnormal terminations; the
  478. X\fBerrorCode\fR variable will contain additional information
  479. Xabout the last abnormal termination encountered.
  480. XIf any of the commands writes to its standard error file,
  481. Xthen \fBexec\fR will return an error, and the error message
  482. Xwill include the pipeline's output, followed by messages
  483. Xabout abnormal terminations (if any), followed by the standard error
  484. Xoutput.
  485. X.PP
  486. XIf the last character of the result or error message
  487. Xis a newline then that character is deleted from the result
  488. Xor error message for consistency with normal
  489. XTcl return values.
  490. X.PP
  491. XIf an \fIarg\fR has the value ``>'' then the
  492. Xfollowing argument is taken as the name of a file and
  493. Xthe standard output of the last command in the pipeline
  494. Xis redirected to the file.  In this situation \fBexec\fR
  495. Xwill normally return an empty string.
  496. X.PP
  497. XIf an \fIarg\fR has the value ``<'' then the following
  498. Xargument is taken as the name of a file to use
  499. Xfor standard input to the first command in the
  500. Xpipeline.
  501. XIf an argument has the value ``<<'' then the following
  502. Xargument is taken as an immediate value to be passed to
  503. Xthe first command as standard input.
  504. XIf there is no ``<'' or ``<<'' argument then the standard
  505. Xinput for the first command in the pipeline is taken from
  506. Xthe application's current standard input.
  507. X.PP
  508. XIf the last \fIarg\fR is ``&'' then the command will be
  509. Xexecuted in background.
  510. XIn this case the standard output from the last command
  511. Xin the pipeline will
  512. Xgo to the application's standard output unless
  513. Xredirected in the command, and error output from all
  514. Xthe commands in the pipeline will go to the application's
  515. Xstandard error file.
  516. X.PP
  517. XEach \fIarg\fR becomes one word for a command, except for
  518. X``|'', ``<'', ``<<'', ``>'', and ``&'' arguments, and the
  519. Xarguments that follow ``<'', ``<<'', and ``>''.
  520. XThe first word in each command is taken as the command name;
  521. Xtilde-substitution is performed on it, and the directories
  522. Xin the PATH environment variable are searched for
  523. Xan executable by the given name.
  524. XNo ``glob'' expansion or other shell-like substitutions
  525. Xare performed on the arguments to commands.
  526. X.RE
  527. X.TP
  528. X\fBexit \fR?returnCode\fR?
  529. XTerminate the process, returning \fIreturnCode\fR to the
  530. Xparent as the exit status.
  531. XIf \fIreturnCode\fR isn't specified then it defaults
  532. Xto 0.
  533. X.VE
  534. X.TP
  535. X\fBexpr \fIarg\fR
  536. XCalls the expression processor to evaluate \fIarg\fR, and returns
  537. Xthe result as a string.  See the section EXPRESSIONS above.
  538. X.TP
  539. X\fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR?
  540. X.VS
  541. XOperate on a file or a file name.  \fIName\fR is the name of a file;
  542. Xif it starts with a tilde, then tilde substitution is done before
  543. Xexecuting the command (see the manual entry for \fBTcl_TildeSubst\fR
  544. Xfor details).
  545. X\fIOption\fR indicates what to do with the file name.  Any unique
  546. Xabbreviation for \fIoption\fR is acceptable.  The valid options are:
  547. X.RS
  548. X.TP
  549. X\fBfile \fBatime \fIname\fR
  550. XReturn a decimal string giving the time at which file \fIname\fR
  551. Xwas last accessed.  The time is measured in the standard UNIX
  552. Xfashion as seconds from a fixed starting time (often January 1, 1970).
  553. XIf the file doesn't exist or its access time cannot be queried then an
  554. Xerror is generated.
  555. X.TP
  556. X\fBfile \fBdirname \fIname\fR
  557. XReturn all of the characters in \fIname\fR up to but not including
  558. Xthe last slash character.  If there are no slashes in \fIname\fR
  559. Xthen return ``.''.  If the last slash in \fIname\fR is its first
  560. Xcharacter, then return ``/''.
  561. X.TP
  562. X\fBfile \fBexecutable \fIname\fR
  563. XReturn \fB1\fR if file \fIname\fR is executable by
  564. Xthe current user, \fB0\fR otherwise.
  565. X.TP
  566. X\fBfile \fBexists \fIname\fR
  567. XReturn \fB1\fR if file \fIname\fR exists and the current user has
  568. Xsearch privileges for the directories leading to it, \fB0\fR otherwise.
  569. X.TP
  570. X\fBfile \fBextension \fIname\fR
  571. XReturn all of the characters in \fIname\fR after and including the
  572. Xlast dot in \fIname\fR.  If there is no dot in \fIname\fR then return
  573. Xthe empty string.
  574. X.TP
  575. X\fBfile \fBisdirectory \fIname\fR
  576. XReturn \fB1\fR if file \fIname\fR is a directory,
  577. X\fB0\fR otherwise.
  578. X.TP
  579. X\fBfile \fBisfile \fIname\fR
  580. XReturn \fB1\fR if file \fIname\fR is a regular file,
  581. X\fB0\fR otherwise.
  582. X.TP
  583. X\fBfile \fBmtime \fIname\fR
  584. XReturn a decimal string giving the time at which file \fIname\fR
  585. Xwas last modified.  The time is measured in the standard UNIX
  586. Xfashion as seconds from a fixed starting time (often January 1, 1970).
  587. XIf the file doesn't exist or its modified time cannot be queried then an
  588. Xerror is generated.
  589. X.TP
  590. X\fBfile \fBowned \fIname\fR
  591. XReturn \fB1\fR if file \fIname\fR is owned by the current user,
  592. X\fB0\fR otherwise.
  593. X.TP
  594. X\fBfile \fBreadable \fIname\fR
  595. XReturn \fB1\fR if file \fIname\fR is readable by
  596. Xthe current user, \fB0\fR otherwise.
  597. X.TP
  598. X\fBfile \fBrootname \fIname\fR
  599. XReturn all of the characters in \fIname\fR up to but not including
  600. Xthe last ``.'' character in the name.  If \fIname\fR doesn't contain
  601. Xa dot, then return \fIname\fR.
  602. X.TP
  603. X\fBfile \fBsize \fIname\fR
  604. XReturn a decimal string giving the size of file \fIname\fR in bytes.
  605. XIf the file doesn't exist or its size cannot be queried then an
  606. Xerror is generated.
  607. X.TP
  608. X\fBfile \fBstat  \fIname\fIvarName\fR
  609. XInvoke the \fBstat\fR kernel call on \fIname\fR, and use the
  610. Xvariable given by \fIvarName\fR to hold information returned from
  611. Xthe kernel call.
  612. X\fIVarName\fR is treated as an array variable,
  613. Xand the following elements of that variable are set: \fBatime\fR,
  614. X\fBctime\fR, \fBdev\fR, \fBgid\fR, \fBino\fR, \fBmode\fR, \fBmtime\fR,
  615. X\fBnlink\fR, \fBsize\fR, \fBuid\fR.
  616. XEach element is a decimal string with the value of the corresponding
  617. Xfield from the \fBstat\fR return structure; see the manual entry
  618. Xfor \fBstat\fR for details on the meanings of the values.
  619. XThis command returns an empty string.
  620. X.TP
  621. X\fBfile \fBtail \fIname\fR
  622. XReturn all of the characters in \fIname\fR after the last slash.
  623. XIf \fIname\fR contains no slashes then return \fIname\fR.
  624. X.TP
  625. X\fBfile \fBwritable \fIname\fR
  626. XReturn \fB1\fR if file \fIname\fR is writable by
  627. Xthe current user, \fB0\fR otherwise.
  628. X.RE
  629. X.IP
  630. XThe \fBfile\fR commands that return 0/1 results are often used in
  631. Xconditional or looping commands, for example:
  632. X.RS
  633. X.DS
  634. X\fBif {![file exists foo]} then {error {bad file name}} else {...}\fR
  635. X.DE
  636. X.VE
  637. X.RE
  638. X.TP
  639. X\fBflush \fIfileId\fR
  640. X.VS
  641. XFlushes any output that has been buffered for \fIfileId\fR.
  642. X\fIFileId\fR must have been the return
  643. Xvalue from a previous call to \fBopen\fR, or it may be
  644. X\fBstdout\fR or \fBstderr\fR to access one of the standard I/O streams;
  645. Xit must refer to a file that was opened for writing.
  646. XThis command returns an empty string.
  647. X.VE
  648. X.TP
  649. X\fBfor \fIstart test next body\fR
  650. X\fBFor\fR is a looping command, similar in structure to the C
  651. X\fBfor\fR statement.  The \fIstart\fR, \fInext\fR, and
  652. X\fIbody\fR arguments must be Tcl command strings, and \fItest\fR
  653. Xis an expression string.
  654. XThe \fBfor\fR command first invokes the Tcl interpreter to
  655. Xexecute \fIstart\fR.  Then it repeatedly evaluates \fItest\fR as
  656. Xan expression; if the result is non-zero it invokes the Tcl
  657. Xinterpreter on \fIbody\fR, then invokes the Tcl interpreter on \fInext\fR,
  658. Xthen repeats the loop.  The command terminates when \fItest\fR evaluates
  659. Xto 0.  If a \fBcontinue\fR command is invoked within \fIbody\fR then
  660. Xany remaining commands in the current execution of \fIbody\fR are skipped;
  661. Xprocessing continues by invoking the Tcl interpreter on \fInext\fR, then
  662. Xevaluating \fItest\fR, and so on.  If a \fBbreak\fR command is invoked
  663. Xwithin \fIbody\fR
  664. Xor \fInext\fR,
  665. Xthen the \fBfor\fR command will
  666. Xreturn immediately.
  667. XThe operation of \fBbreak\fR and \fBcontinue\fR are similar to the
  668. Xcorresponding statements in C.
  669. X\fBFor\fR returns an empty string.
  670. X.TP
  671. X\fBforeach \fIvarname list body\fR
  672. XIn this command, \fIvarname\fR is the name of a variable, \fIlist\fR
  673. Xis a list of values to assign to \fIvarname\fR, and \fIbody\fR is a
  674. Xcollection of Tcl commands.  For each field in \fIlist\fR (in order
  675. Xfrom left to right), \fBforeach\fR assigns the contents of the
  676. Xfield to \fIvarname\fR (as if the \fBlindex\fR command had been used
  677. Xto extract the field), then calls the Tcl interpreter to execute
  678. X\fIbody\fR.  The \fBbreak\fR and \fBcontinue\fR statements may be
  679. Xinvoked inside \fIbody\fR, with the same effect as in the \fBfor\fR
  680. Xcommand.  \fBForeach\fR an empty string.
  681. X.TP
  682. X\fBformat \fIformatString \fR?\fIarg arg ...\fR?
  683. XThis command generates a formatted string in the same way as the
  684. XC \fBsprintf\fR procedure (it uses \fBsprintf\fR in its
  685. Ximplementation).  \fIFormatString\fR indicates how to format
  686. Xthe result, using \fB%\fR fields as in \fBsprintf\fR, and the additional
  687. Xarguments, if any, provide values to be substituted into the result.
  688. XAll of the \fBsprintf\fR options are valid; see the \fBsprintf\fR
  689. Xman page for details.  Each \fIarg\fR must match the expected type
  690. Xfrom the \fB%\fR field in \fIformatString\fR; the \fBformat\fR command
  691. Xconverts each argument to the correct type (floating, integer, etc.)
  692. Xbefore passing it to \fBsprintf\fR for formatting.
  693. XThe only unusual conversion is for \fB%c\fR; in this case the argument
  694. Xmust be a decimal string, which will then be converted to the corresponding
  695. XASCII character value.
  696. X\fBFormat\fR does backslash substitution on its \fIformatString\fR
  697. Xargument, so backslash sequences in \fIformatString\fR will be handled
  698. Xcorrectly even if the argument is in braces.
  699. XThe return value from \fBformat\fR
  700. Xis the formatted string.
  701. X.TP
  702. X\fBgets \fIfileId\fR ?\fIvarName\fR?
  703. X.VS
  704. XReads the next line from the file given by \fIfileId\fR and discards
  705. Xthe terminating newline character.
  706. XIf \fIvarName\fR is specified, then the line is placed in the variable
  707. Xby that name and the return value is a count of the number of characters
  708. Xread (not including the newline).
  709. XIf the end of the file is reached before reading
  710. Xany characters then \-1 is returned and \fIvarName\fR is set to an
  711. Xempty string.
  712. XIf \fIvarName\fR is not specified then the return value will be
  713. Xthe line (minus the newline character) or an empty string if
  714. Xthe end of the file is reached before reading any characters.
  715. XAn empty string will also be returned if a line contains no characters
  716. Xexcept the newline, so \fBeof\fR may have to be used to determine
  717. Xwhat really happened.
  718. XIf the last character in the file is not a newline character, then
  719. X\fBgets\fR behaves as if there were an additional newline character
  720. Xat the end of the file.
  721. X\fIFileId\fR must be \fBstdin\fR or the return value from a previous
  722. Xcall to \fBopen\fR; it must refer to a file that was opened
  723. Xfor reading.
  724. X.VE
  725. X.TP
  726. X\fBglob \fR?\fB\-nocomplain\fR? \fIfilename\fR ?\fIfilename ...\fR?
  727. XThis command performs filename globbing, using csh rules.  The returned
  728. Xvalue from \fBglob\fR is the list of expanded filenames.
  729. X.VS
  730. XIf \fB\-nocomplain\fR is specified as the first argument then an empty
  731. Xlist may be returned;  otherwise an error is returned if the expanded
  732. Xlist is empty.  The \fB\-nocomplain\fR argument must be provided
  733. Xexactly: an abbreviation will not be accepted.
  734. X.VE
  735. X.TP
  736. X\fBglobal \fIvarname \fR?\fIvarname ...\fR?
  737. XThis command is ignored unless a Tcl procedure is being interpreted.
  738. XIf so, then it declares the given \fIvarname\fR's to be global variables
  739. Xrather than local ones.  For the duration of the current procedure
  740. X(and only while executing in the current procedure), any reference to
  741. Xany of the \fIvarname\fRs will be bound to a global variable instead
  742. Xof a local one.
  743. X.TP
  744. X\fBhistory \fR?\fIoption\fR? ?\fIarg arg ...\fR?
  745. XNote:  this command may not be available in all Tcl-based applications.
  746. XTypically, only those that receive command input in a typescript
  747. Xform will support history.
  748. XThe \fBhistory\fR command performs one of several operations related to
  749. Xrecently-executed commands recorded in a history list.  Each of
  750. Xthese recorded commands is referred to as an ``event''.  When
  751. Xspecifying an event to the \fBhistory\fR command, the following
  752. Xforms may be used:
  753. X.RS
  754. X.IP [1]
  755. XA number:  if positive, it refers to the event with
  756. Xthat number (all events are numbered starting at 1).  If the number
  757. Xis negative, it selects an event relative to the current event
  758. X(\fB\-1\fR refers to the previous event, \fB\-2\fR to the one before that, and
  759. Xso on).
  760. X.IP [2]
  761. XA string:  selects the most recent event that matches the string.
  762. XAn event is considered to match the string either if the string is
  763. Xthe same as the first characters of the event, or if the string
  764. Xmatches the event in the sense of the \fBstring match\fR command.
  765. X.LP
  766. XThe \fBhistory\fR command can take any of the following forms:
  767. X.TP
  768. X\fBhistory\fR
  769. XSame
  770. X.VS
  771. Xas \fBhistory info\fR, described below.
  772. X.VE
  773. X.TP
  774. X\fBhistory add\fI command \fR?\fBexec\fR?
  775. XAdd the \fIcommand\fR argument to the history list as a new event.  If
  776. X\fBexec\fR is specified (or abbreviated) then the command is also
  777. Xexecuted and its result is returned.  If \fBexec\fR isn't specified
  778. Xthen an empty string is returned as result.
  779. X.TP
  780. X\fBhistory change\fI newValue\fR ?\fIevent\fR?
  781. XReplace the value recorded for an event with \fInewValue\fR.  \fIEvent\fR
  782. Xspecifies the event to replace, and
  783. Xdefaults to the \fIcurrent\fR event (not event \fB\-1\fR).  This command
  784. Xis intended for use in commands that implement new forms of history
  785. Xsubstitution and wish to replace the current event (which invokes the
  786. Xsubstitution) with the command created through substitution.  The return
  787. Xvalue is an empty string.
  788. X.TP
  789. X\fBhistory event\fR ?\fIevent\fR?
  790. XReturns the value of the event given by \fIevent\fR.  \fIEvent\fR
  791. Xdefaults to \fB\-1\fR.  This command causes history revision to occur:
  792. Xsee below for details.
  793. X.TP
  794. X\fBhistory info \fR?\fIcount\fR?
  795. XReturns a formatted string (intended for humans to read) giving
  796. Xthe event number and contents for each of the events in the history
  797. Xlist except the current event.  If \fIcount\fR is specified
  798. Xthen only the most recent \fIcount\fR events are returned.
  799. X.TP
  800. X\fBhistory keep \fIcount\fR
  801. XThis command may be used to change the size of the history list to
  802. X\fIcount\fR events.  Initially, 20 events are retained in the history
  803. Xlist.  This command returns an empty string.
  804. X.TP
  805. X\fBhistory nextid\fR
  806. XReturns the number of the next event to be recorded
  807. Xin the history list.  It is useful for things like printing the
  808. Xevent number in command-line prompts.
  809. X.TP
  810. X\fBhistory redo \fR?\fIevent\fR?
  811. XRe-execute the command indicated by \fIevent\fR and return its result.
  812. X\fIEvent\fR defaults to \fB\-1\fR.  This command results in history
  813. Xrevision:  see below for details.
  814. X.TP
  815. X\fBhistory substitute \fIold new \fR?\fIevent\fR?
  816. XRetrieve the command given by \fIevent\fR
  817. X(\fB\-1\fR by default), replace any occurrences of \fIold\fR by
  818. X\fInew\fR in the command (only simple character equality is supported;
  819. Xno wild cards), execute the resulting command, and return the result
  820. Xof that execution.  This command results in history
  821. Xrevision:  see below for details.
  822. X.TP
  823. X\fBhistory words \fIselector\fR ?\fIevent\fR?
  824. XRetrieve from the command given by \fIevent\fR (\fB\-1\fR by default)
  825. Xthe words given by \fIselector\fR, and return those words in a string
  826. Xseparated by spaces.  The \fBselector\fR argument has three forms.
  827. XIf it is a single number then it selects the word given by that
  828. Xnumber (\fB0\fR for the command name, \fB1\fR for its first argument,
  829. Xand so on).  If it consists of two numbers separated by a dash,
  830. Xthen it selects all the arguments between those two.  Otherwise
  831. X\fBselector\fR is treated as a pattern; all words matching that
  832. Xpattern (in the sense of \fBstring match\fR) are returned.  In
  833. Xthe numeric forms \fB$\fR may be used
  834. Xto select the last word of a command.
  835. XFor example, suppose the most recent command in the history list is
  836. X.RS
  837. X.DS
  838. X\fBformat  {%s is %d years old} Alice [expr $ageInMonths/12]\fR
  839. X.DE
  840. XBelow are some history commands and the results they would produce:
  841. X.DS
  842. X.ta 4c
  843. X.fi
  844. X.UL Command "    "
  845. X.UL Result
  846. X.nf
  847. X
  848. X\fBhistory words $    [expr $ageInMonths/12]\fR
  849. X\fBhistory words 1-2    {%s is %d years  old} Alice\fR
  850. X\fBhistory words *a*o*    {%s is %d years old} [expr $ageInMonths/12]\fR
  851. X.DE
  852. X\fBHistory words\fR results in history revision:  see below for details.
  853. X.RE
  854. XThe history options \fBevent\fR, \fBredo\fR, \fBsubstitute\fR,
  855. Xand \fBwords\fR result in ``history revision''.
  856. XWhen one of these options is invoked then the current event
  857. Xis modified to eliminate the history command and replace it with
  858. Xthe result of the history command.
  859. XFor example, suppose that the most recent command in the history
  860. Xlist is
  861. X.DS
  862. X\fBset a [expr $b+2]\fR
  863. X.DE
  864. Xand suppose that the next command invoked is one of the ones on
  865. Xthe left side of the table below.  The command actually recorded in
  866. Xthe history event will be the corresponding one on the right side
  867. Xof the table.
  868. X.ne 1.5c
  869. X.DS
  870. X.ta 4c
  871. X.fi
  872. X.UL "Command Typed" "    "
  873. X.UL "Command Recorded"
  874. X.nf
  875. X
  876. X\fBhistory    set a [expr $b+2]\fR
  877. X\fBhistory s a b    set b [expr $b+2]\fR
  878. X\fBset c [history w 2]    set c [expr $b+2]\fR
  879. X.DE
  880. X.VS
  881. XHistory revision is needed because event specifiers like \fB\-1\fR
  882. Xare only valid at a particular time:  once more events have been
  883. Xadded to the history list a different event specifier would be
  884. Xneeded.
  885. XHistory revision occurs even when \fBhistory\fR is invoked
  886. Xindirectly from the current event (e.g. a user types a command
  887. Xthat invokes a Tcl procedure that invokes \fBhistory\fR):  the
  888. Xtop-level command whose execution eventually resulted in a
  889. X\fBhistory\fR command is replaced.
  890. XIf you wish to invoke commands like \fBhistory words\fR without
  891. Xhistory revision, you can use \fBhistory event\fR to save the
  892. Xcurrent history event and then use \fBhistory change\fR to
  893. Xrestore it later.
  894. X.VE
  895. X.VE
  896. X.RE
  897. X.TP
  898. X\fBif \fItest \fR?\fBthen\fR? \fItrueBody \fR?\fBelse\fR? ?\fIfalseBody\fR?
  899. XThe \fIif\fR command evaluates \fItest\fR as an expression (in the
  900. Xsame way that \fBexpr\fR evaluates its argument).  The value of the
  901. Xexpression must be numeric; if it
  902. Xis non-zero then \fItrueBody\fR is called by passing it to the
  903. XTcl interpreter.  Otherwise \fIfalseBody\fR is executed by passing it to
  904. Xthe Tcl interpreter.  The \fBthen\fR and \fBelse\fR arguments are optional
  905. X``noise words'' to make the command easier to read.  \fIFalseBody\fR is
  906. Xalso optional; if it isn't specified then the command does nothing if
  907. X\fItest\fR evaluates to zero.  The return value from \fBif\fR is
  908. Xthe value of the last command executed in \fItrueBody\fR or
  909. X\fIfalseBody\fR, or the empty string if \fItest\fR evaluates to zero and
  910. X\fIfalseBody\fR isn't specified.
  911. X.TP
  912. X\fBincr \fIvarName \fR?\fIincrement\fR?
  913. X.VS
  914. XIncrement the value stored in the variable whose name is \fIvarName\fR.
  915. XThe value of the variable must be integral.
  916. XIf \fIincrement\fR is supplied then its value (which must be an
  917. Xinteger) is added to the value of variable \fIvarName\fR;  otherwise
  918. X1 is added to \fIvarName\fR.
  919. XThe new value is stored as a decimal string in variable \fIvarName\fR
  920. Xand also returned as result.
  921. X.VE
  922. X.TP
  923. X\fBinfo \fIoption \fR?\fIarg arg ...\fR?
  924. XProvide information about various internals to the Tcl interpreter.
  925. XThe legal \fIoption\fR's (which may be abbreviated) are:
  926. X.RS
  927. X.TP
  928. X\fBinfo args \fIprocname\fR
  929. XReturns a list containing the names of the arguments to procedure
  930. X\fIprocname\fR, in order.  \fIProcname\fR must be the name of a
  931. XTcl command procedure.
  932. X.TP
  933. X\fBinfo body \fIprocname\fR
  934. XReturns the body of procedure \fIprocname\fR.  \fIProcname\fR must be
  935. Xthe name of a Tcl command procedure.
  936. X.TP
  937. X\fBinfo cmdcount\fR
  938. XReturns a count of the total number of commands that have been invoked
  939. Xin this interpreter.
  940. X.TP
  941. X\fBinfo commands \fR?\fIpattern\fR?
  942. XIf \fIpattern\fR isn't specified, returns a list of names of all the
  943. XTcl commands, including both the built-in commands written in C and
  944. Xthe command procedures defined using the \fBproc\fR command.
  945. XIf \fIpattern\fR is specified, only those names matching \fIpattern\fR
  946. Xare returned.  Matching is determined using the same rules as for
  947. X\fBstring match\fR.
  948. X.TP
  949. X\fBinfo default \fIprocname arg varname\fR
  950. X\fIProcname\fR must be the name of a Tcl command procedure and \fIarg\fR
  951. Xmust be the name of an argument to that procedure.  If \fIarg\fR
  952. Xdoesn't have a default value then the command returns \fB0\fR.
  953. XOtherwise it returns \fB1\fR and places the default value of \fIarg\fR
  954. Xinto variable \fIvarname\fR.
  955. X.TP
  956. X\fBinfo exists \fIvarName\fR
  957. XReturns \fB1\fR if the variable named \fIvarName\fR exists in the
  958. Xcurrent context (either as a global or local variable), returns \fB0\fR
  959. Xotherwise.
  960. X.TP
  961. X\fBinfo globals \fR?\fIpattern\fR?
  962. XIf \fIpattern\fR isn't specified, returns a list of all the names
  963. Xof currently-defined global variables.
  964. XIf \fIpattern\fR is specified, only those names matching \fIpattern\fR
  965. Xare returned.  Matching is determined using the same rules as for
  966. X\fBstring match\fR.
  967. X.TP
  968. X\fBinfo level\fR ?\fInumber\fR?
  969. XIf \fInumber\fR is not specified, this command returns a number
  970. Xgiving the stack level of the invoking procedure, or 0 if the
  971. Xcommand is invoked at top-level.  If \fInumber\fR is specified,
  972. Xthen the result is a list consisting of the name and arguments for the
  973. Xprocedure call at level \fInumber\fR on the stack.  If \fInumber\fR
  974. Xis positive then it selects a particular stack level (1 refers
  975. Xto the top-most active procedure, 2 to the procedure it called, and
  976. Xso on); otherwise it gives a level relative to the current level
  977. X(0 refers to the current procedure, -1 to its caller, and so on).
  978. XSee the \fBuplevel\fR command for more information on what stack
  979. Xlevels mean.
  980. X.TP
  981. X\fBinfo library\fR
  982. X.VS
  983. XReturns the name of the library directory in which standard Tcl
  984. Xscripts are stored.
  985. XIf there is no such directory defined for the current installation
  986. Xthen an error is generated.
  987. XSee the \fBlibrary\fR manual entry for details of the facilities
  988. Xprovided by the Tcl script library.
  989. XNormally each application will have its own application-specific
  990. Xscript library in addition to the Tcl script library;  I suggest that
  991. Xeach application set a global variable with a name like
  992. X\fB$\fIapp\fBLibrary\fR (where \fIapp\fR is the application's name)
  993. Xto hold the location of that application's library directory.
  994. X.VE
  995. X.TP
  996. X\fBinfo locals \fR?\fIpattern\fR?
  997. XIf \fIpattern\fR isn't specified, returns a list of all the names
  998. Xof currently-defined local variables, including arguments to the
  999. Xcurrent procedure, if any.
  1000. X.VS
  1001. XVariables defined with the \fBglobal\fR and \fBupvar\fR commands
  1002. Xwill not be returned.
  1003. X.VE
  1004. XIf \fIpattern\fR is specified, only those names matching \fIpattern\fR
  1005. Xare returned.  Matching is determined using the same rules as for
  1006. X\fBstring match\fR.
  1007. X.TP
  1008. X\fBinfo procs \fR?\fIpattern\fR?
  1009. XIf \fIpattern\fR isn't specified, returns a list of all the
  1010. Xnames of Tcl command procedures.
  1011. XIf \fIpattern\fR is specified, only those names matching \fIpattern\fR
  1012. Xare returned.  Matching is determined using the same rules as for
  1013. X\fBstring match\fR.
  1014. X.TP
  1015. X\fBinfo script\fR
  1016. X.VS
  1017. XIf a Tcl script file is currently being evaluated (i.e. there is a
  1018. Xcall to \fBTcl_EvalFile\fR active or there is an active invocation
  1019. Xof the \fBsource\fR command), then this command returns the name
  1020. Xof the innermost file being processed.  Otherwise the command returns an
  1021. Xempty string.
  1022. X.VE
  1023. X.TP
  1024. X\fBinfo tclversion\fR
  1025. XReturns the version number for this version of Tcl in the form \fIx.y\fR,
  1026. Xwhere changes to \fIx\fR represent major changes with probable
  1027. Xincompatibilities and changes to \fIy\fR represent small enhancements and
  1028. Xbug fixes that retain backward compatibility.
  1029. END_OF_FILE
  1030. if test 41756 -ne `wc -c <'tcl6.1/doc/Tcl.man.2'`; then
  1031.     echo shar: \"'tcl6.1/doc/Tcl.man.2'\" unpacked with wrong size!
  1032. fi
  1033. # end of 'tcl6.1/doc/Tcl.man.2'
  1034. fi
  1035. echo shar: End of archive 33 \(of 33\).
  1036. cp /dev/null ark33isdone
  1037. MISSING=""
  1038. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  1039.     if test ! -f ark${I}isdone ; then
  1040.     MISSING="${MISSING} ${I}"
  1041.     fi
  1042. done
  1043. if test "${MISSING}" = "" ; then
  1044.     echo You have unpacked all 33 archives.
  1045.     echo "Combining tclVar.c.1 and tclVar.c.2 to produce tclVar.c..."
  1046.     cat tcl6.1/tclVar.c.1 tcl6.1/tclVar.c.2 >tcl6.1/tclVar.c
  1047.     echo "Combining Tcl.man.1, Tcl.man.2 and Tcl.man.3 to produce Tcl.man..."
  1048.     cat tcl6.1/doc/Tcl.man.1 tcl6.1/doc/Tcl.man.2 \
  1049.         tcl6.1/doc/Tcl.man.3 >tcl6.1/doc/Tcl.man
  1050.     echo "Now cd to tcl6.1, do a 'csh ./config' and a 'make'"
  1051.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1052. else
  1053.     echo You still need to unpack the following archives:
  1054.     echo "        " ${MISSING}
  1055. fi
  1056. ##  End of shell archive.
  1057. exit 0
  1058.  
  1059. exit 0 # Just in case...
  1060. -- 
  1061. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1062. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1063. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1064. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1065.