2 source - Evaluate a file or resource as a Tcl script
7 source -rsrc resourceName ?fileName?
9 source -rsrcid resourceId ?fileName?
13 This command takes the contents of the specified file or resource and
14 passes it to the Tcl interpreter as a text script. The return value
15 from source is the return value of the last command executed in the
16 script. If an error occurs in evaluating the contents of the script
17 then the source command will return that error. If a return command is
18 invoked from within the script then the remainder of the file will be
19 skipped and the source command will return normally with the result
20 from the return command.
22 The end-of-file character for files is '\32' (^Z) for all platforms.
23 The source command will read files up to this character. This restric-
24 tion does not exist for the read or gets commands, allowing for files
25 containing code and data segments (scripted documents). If you require
26 a ``^Z'' in code for string comparison, you can use ``\032'' or
27 ``\u001a'', which will be safely substituted by the Tcl interpreter
30 The -rsrc and -rsrcid forms of this command are only available on Mac-
31 intosh computers. These versions of the command allow you to source a
32 script from a TEXT resource. You may specify what TEXT resource to
33 source by either name or id. By default Tcl searches all open resource
34 files, which include the current application and any loaded C exten-
35 sions. Alternatively, you may specify the fileName where the TEXT
36 resource can be found.
39 Run the script in the file foo.tcl and then the script in the file
44 foreach scriptFile {foo.tcl bar.tcl} {
50 file(n), cd(n), info(n)