Debian Codegraph @

doc/source.n

raw
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 .TH source n "" Tcl "Tcl Built-In Commands"
10 .so man.macros
11 .BS
12 '\" Note: do not modify the .SH NAME line immediately below!
13 .SH NAME
14 source \- Evaluate a file or resource as a Tcl script
15 .SH SYNOPSIS
16 \fBsource \fIfileName\fR
17 .sp
18 \fBsource\fR \fB\-encoding \fIencodingName fileName\fR
19 .BE
20 .SH DESCRIPTION
21 .PP
22 This command takes the contents of the specified file or resource
23 and passes it to the Tcl interpreter as a text script. The return
24 value from \fBsource\fR is the return value of the last command
25 executed in the script. If an error occurs in evaluating the contents
26 of the script then the \fBsource\fR command will return that error.
27 If a \fBreturn\fR command is invoked from within the script then the
28 remainder of the file will be skipped and the \fBsource\fR command
29 will return normally with the result from the \fBreturn\fR command.
30 .PP
31 The end-of-file character for files is
32 .QW \e32
33 (^Z) for all platforms.
34 The source command will read files up to this character. This
35 restriction does not exist for the \fBread\fR or \fBgets\fR commands,
36 allowing for files containing code and data segments (scripted documents).
37 If you require a
38 .QW ^Z
39 in code for string comparison, you can use
40 .QW \e032
41 or
42 .QW \eu001a ,
43 which will be safely substituted by the Tcl interpreter into
44 .QW ^Z .
45 .PP
46 A leading BOM (Byte order mark) contained in the file is ignored for unicode encodings (utf-8, unicode).
47 .PP
48 The \fB\-encoding\fR option is used to specify the encoding of
49 the data stored in \fIfileName\fR. When the \fB\-encoding\fR option
50 is omitted, the system encoding is assumed.
51 .SH EXAMPLE
52 .PP
53 Run the script in the file \fBfoo.tcl\fR and then the script in the
54 file \fBbar.tcl\fR:
55 .PP
56 .CS
57 \fBsource\fR foo.tcl
58 \fBsource\fR bar.tcl
59 .CE
60 .PP
61 Alternatively:
62 .PP
63 .CS
64 foreach scriptFile {foo.tcl bar.tcl} {
65 \fBsource\fR $scriptFile
66 }
67 .CE
68 .SH "SEE ALSO"
69 file(n), cd(n), encoding(n), info(n)
70 .SH KEYWORDS
71 file, script