Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / share / tcl / help / tcl / control / source
1 NAME
2 source - Evaluate a file or resource as a Tcl script
3
4 SYNOPSIS
5 source fileName
6
7 source -rsrc resourceName ?fileName?
8
9 source -rsrcid resourceId ?fileName?
10
11
12 DESCRIPTION
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.
21
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
28 into ``^Z''.
29
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.
37
38 EXAMPLE
39 Run the script in the file foo.tcl and then the script in the file
40 bar.tcl:
41 source foo.tcl
42 source bar.tcl
43 Alternatively:
44 foreach scriptFile {foo.tcl bar.tcl} {
45 source $scriptFile
46 }
47
48
49 SEE ALSO
50 file(n), cd(n), info(n)
51
52
53 KEYWORDS