1source(n) Tcl Built-In Commands source(n)
2
3
4
5______________________________________________________________________________
6
8 source - Evaluate a file or resource as a Tcl script
9
11 source fileName
12
13 source -encoding encodingName fileName │
14_________________________________________________________________
15
17 This command takes the contents of the specified file or resource and
18 passes it to the Tcl interpreter as a text script. The return value
19 from source is the return value of the last command executed in the
20 script. If an error occurs in evaluating the contents of the script
21 then the source command will return that error. If a return command is
22 invoked from within the script then the remainder of the file will be
23 skipped and the source command will return normally with the result
24 from the return command.
25
26 The end-of-file character for files is “\32” (^Z) for all platforms.
27 The source command will read files up to this character. This restric‐
28 tion does not exist for the read or gets commands, allowing for files
29 containing code and data segments (scripted documents). If you require
30 a “^Z” in code for string comparison, you can use “\032” or “\u001a”,
31 which will be safely substituted by the Tcl interpreter into “^Z”.
32
33 The -encoding option is used to specify the encoding of the data stored │
34 in fileName. When the -encoding option is omitted, the system encoding │
35 is assumed.
36
38 Run the script in the file foo.tcl and then the script in the file
39 bar.tcl:
40 source foo.tcl
41 source bar.tcl
42 Alternatively:
43 foreach scriptFile {foo.tcl bar.tcl} {
44 source $scriptFile
45 }
46
48 file(n), cd(n), encoding(n), info(n)
49
51 file, script
52
53
54
55Tcl source(n)