Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/source.n @ 37

Last change on this file since 37 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 2.2 KB
Line 
1'\"
2'\" Copyright (c) 1993 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\" Copyright (c) 2000 Scriptics Corporation.
5'\"
6'\" See the file "license.terms" for information on usage and redistribution
7'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8'\"
9'\" RCS: @(#) $Id: source.n,v 1.18 2007/12/13 15:22:33 dgp Exp $
10'\"
11.so man.macros
12.TH source n "" Tcl "Tcl Built-In Commands"
13.BS
14'\" Note:  do not modify the .SH NAME line immediately below!
15.SH NAME
16source \- Evaluate a file or resource as a Tcl script
17.SH SYNOPSIS
18\fBsource \fIfileName\fR
19.sp
20.VS 8.5
21\fBsource\fR \fB\-encoding \fIencodingName fileName\fR
22.VE 8.5
23.BE
24.SH DESCRIPTION
25.PP
26This command takes the contents of the specified file or resource
27and passes it to the Tcl interpreter as a text script.  The return
28value from \fBsource\fR is the return value of the last command
29executed in the script.  If an error occurs in evaluating the contents
30of the script then the \fBsource\fR command will return that error.
31If a \fBreturn\fR command is invoked from within the script then the
32remainder of the file will be skipped and the \fBsource\fR command
33will return normally with the result from the \fBreturn\fR command.
34.PP
35The end-of-file character for files is
36.QW \e32
37(^Z) for all platforms.
38The source command will read files up to this character.  This
39restriction does not exist for the \fBread\fR or \fBgets\fR commands,
40allowing for files containing code and data segments (scripted documents).
41If you require a
42.QW ^Z
43in code for string comparison, you can use
44.QW \e032
45or
46.QW \eu001a ,
47which will be safely substituted by the Tcl interpreter into
48.QW ^Z .
49.PP
50.VS 8.5
51The \fB\-encoding\fR option is used to specify the encoding of
52the data stored in \fIfileName\fR.  When the \fB\-encoding\fR option
53is omitted, the system encoding is assumed.
54.VE 8.5
55.SH EXAMPLE
56Run the script in the file \fBfoo.tcl\fR and then the script in the
57file \fBbar.tcl\fR:
58.CS
59\fBsource\fR foo.tcl
60\fBsource\fR bar.tcl
61.CE
62Alternatively:
63.CS
64foreach scriptFile {foo.tcl bar.tcl} {
65   \fBsource\fR $scriptFile
66}
67.CE
68.SH "SEE ALSO"
69file(n), cd(n), encoding(n), info(n)
70.SH KEYWORDS
71file, script
Note: See TracBrowser for help on using the repository browser.