source(1T) Tcl Built-In Commands source(1T)__________________________________________________________________________________________________________________________________________________NAME
source - Evaluate a file or resource as a Tcl script
SYNOPSIS
source fileName
source -rsrc resourceName ?fileName?
source -rsrcid resourceId ?fileName?
_________________________________________________________________DESCRIPTION
This command takes the contents of the specified file or resource and passes it to the Tcl interpreter as a text script. The return value
from source is the return value of the last command executed in the script. If an error occurs in evaluating the contents of the script
then the source command will return that error. If a return command is invoked from within the script then the remainder of the file will
be skipped and the source command will return normally with the result from the return command.
The end-of-file character for files is '32' (^Z) for all platforms. The source command will read files up to this character. This |
restriction does not exist for the read or gets commands, allowing for files containing code and data segments (scripted documents). If |
you require a ``^Z'' in code for string comparison, you can use `` 32'' or ``u001a'', which will be safely substituted by the Tcl inter- |
preter into ``^Z''.
The -rsrc and -rsrcid forms of this command are only available on Macintosh computers. These versions of the command allow you to source a
script from a TEXT resource. You may specify what TEXT resource to source by either name or id. By default Tcl searches all open resource
files, which include the current application and any loaded C extensions. Alternatively, you may specify the fileName where the TEXT
resource can be found.
EXAMPLE
Run the script in the file foo.tcl and then the script in the file bar.tcl:
source foo.tcl
source bar.tcl
Alternatively:
foreach scriptFile {foo.tcl bar.tcl} {
source $scriptFile
}
SEE ALSO file(1T), cd(1T), info(1T)KEYWORDS
file, script
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+--------------------+-----------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-----------------+
|Availability | SUNWTcl |
+--------------------+-----------------+
|Interface Stability | Uncommitted |
+--------------------+-----------------+
NOTES
Source for Tcl is available on http://opensolaris.org.
Tclsource(1T)
Check Out this Related Man Page
Tcl_MacSetEventProc(3TCL) Tcl Library Procedures Tcl_MacSetEventProc(3TCL)__________________________________________________________________________________________________________________________________________________NAME
Tcl_MacSetEventProc, Tcl_MacConvertTextResource, Tcl_MacEvalResource, Tcl_MacFindResource, Tcl_GetOSTypeFromObj, Tcl_SetOSTypeObj,
Tcl_NewOSTypeObj - procedures to handle Macintosh resources and other Macintosh specifics
SYNOPSIS
#include <tcl.h>
int
Tcl_MacEvalResource(interp, resourceName, resourceNumber, fileName)
char*
Tcl_MacConvertTextResource(resource)
Handle
Tcl_MacFindResource(interp, resourceType, resourceName, resourceNumber, resFileRef, releaseIt)
Tcl_Obj*
Tcl_NewOSTypeObj(newOSType)
void
Tcl_SetOSTypeObj(objPtr, newOSType)
int
Tcl_GetOSTypeFromObj(interp, objPtr, osTypePtr)
void
Tcl_MacSetEventProc(procPtr)
ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for error reporting, or NULL if no error reporting is desired.
CONST char *resourceName (in) Name of TEXT resource to source, NULL if number should be used.
int resourceNumber (in) Resource id of source.
CONST char *fileName (in) Name of file to process. NULL if application resource.
Handle resource (in) Handle to TEXT resource.
long resourceType (in) Type of resource to load.
CONST char *resFileRef (in) Registered resource file reference, NULL if searching all open resource files.
int *releaseIt (out) Should we release this resource when done.
int newOSType (in) Int used to initialize the new object or set the object's value.
Tcl_Obj *objPtr (in) Object whose internal representation is to be set or retrieved.
osTypePtr out Place to store the resulting integer.
Tcl_MacConvertEventPtr procPtr(in)
Reference to the new function to handle all incoming Mac events.
_________________________________________________________________INTRODUCTION
The described routines are used to implement the Macintosh specific resource command and the Mac specific notifier.. They manipulate or use
Macintosh resources and provide administration for open resource file references.
DESCRIPTION
Tcl_MacEvalResource extends the source command to Macintosh resources. It sources Tcl code from a Text resource. Currently only sources
the resource by name, file IDs may be supported at a later date.
Tcl_MacConvertTextResource converts a TEXT resource into a Tcl suitable string. It mallocs the returned memory, converts ``
'' to ``
'',
and appends a null. The caller has the responsibility for freeing the memory.
Tcl_MacFindResource provides a higher level interface for loading resources. It is used by resource read.
Tcl_NewOSTypeObj is used to create a new resource name type object. The object type is "ostype".
Tcl_SetOSTypeObj modifies an object to be a resource type and to have the specified long value.
Tcl_GetOSTypeFromObj attempts to return an int from the Tcl object "objPtr". If the object is not already an int, an attempt will be made
to convert it to one.
Tcl_MacSetEventProc sets the event handling procedure for the application. This function will be passed all incoming Mac events. This
function usually controls the console or some other entity like Tk.
RESOURCE TYPES
Resource types are 4-byte values used by the macintosh resource facility to tag parts of the resource fork in a file so that the OS knows
how to handle them. As all 4 bytes are restricted to printable characters such a type can be interpreted as a 4 character string too.
KEYWORDS
macintosh, mac, resource, notifier
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+--------------------+-----------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-----------------+
|Availability | SUNWTcl |
+--------------------+-----------------+
|Interface Stability | Uncommitted |
+--------------------+-----------------+
NOTES
Source for Tcl is available on http://opensolaris.org.
Tcl 8.1 Tcl_MacSetEventProc(3TCL)