1resource(n) Tcl Built-In Commands resource(n)
2
3
4
5______________________________________________________________________________
6
8 resource - Manipulate Macintosh resources
9
11 resource option ?arg arg ...?
12_________________________________________________________________
13
14
16 The resource command provides some generic operations for dealing with
17 Macintosh resources. This command is only supported on the Macintosh
18 platform. Each Macintosh file consists of two forks: a data fork and a
19 resource fork. You use the normal open, puts, close, etc. commands to
20 manipulate the data fork. You must use this command, however, to
21 interact with the resource fork. Option indicates what resource com‐
22 mand to perform. Any unique abbreviation for option is acceptable.
23 The valid options are:
24
25 resource close rsrcRef
26 Closes the given resource reference (obtained from resource
27 open). Resources from that resource file will no longer be
28 available.
29
30 resource delete ?options? resourceType
31 This command will delete the resource specified by options and
32 type resourceType (see RESOURCE TYPES below). The options give
33 you several ways to specify the resource to be deleted.
34
35 -id resourceId
36 If the -id option is given the id resourceId (see
37 RESOURCE IDS below) is used to specify the resource to be
38 deleted. The id must be a number - to specify a name use
39 the -name option.
40
41 -name resourceName
42 If -name is specified, the resource named resourceName
43 will be deleted. If the -id is also provided, then there
44 must be a resource with BOTH this name and this id. If
45 no name is provided, then the id will be used regardless
46 of the name of the actual resource.
47
48 -file resourceRef
49 If the -file option is specified then the resource will
50 be deleted from the file pointed to by resourceRef. Oth‐
51 erwise the first resource with the given resourceName and
52 or resourceId which is found on the resource file path
53 will be deleted. To inspect the file path, use the
54 resource files command.
55
56 resource files ?resourceRef?
57 If resourceRefis not provided, this command returns a Tcl list
58 of the resource references for all the currently open resource
59 files. The list is in the normal Macintosh search order for
60 resources. If resourceRef is specified, the command will return
61 the path to the file whose resource fork is represented by that
62 token.
63
64 resource list resourceType ?resourceRef?
65 List all of the resources ids of type resourceType (see RESOURCE
66 TYPES below). If resourceRef is specified then the command will
67 limit the search to that particular resource file. Otherwise,
68 all resource files currently opened by the application will be
69 searched. A Tcl list of either the resource name's or resource
70 id's of the found resources will be returned. See the RESOURCE
71 IDS section below for more details about what a resource id is.
72
73 resource open fileName ?access?
74 Open the resource for the file fileName. Standard file access
75 permissions may also be specified (see the manual entry for open
76 for details). A resource reference (resourceRef) is returned
77 that can be used by the other resource commands. An error can
78 occur if the file doesn't exist or the file does not have a
79 resource fork. However, if you open the file with write permis‐
80 sions the file and/or resource fork will be created instead of
81 generating an error.
82
83 resource read resourceType resourceId ?resourceRef?
84 Read the entire resource of type resourceType (see RESOURCE
85 TYPES below) and the name or id of resourceId (see RESOURCE IDS
86 below) into memory and return the result. If resourceRef is
87 specified we limit our search to that resource file, otherwise
88 we search all open resource forks in the application. It is
89 important to note that most Macintosh resource use a binary for‐
90 mat and the data returned from this command may have embedded
91 NULLs or other non-ASCII data.
92
93 resource types ?resourceRef?
94 This command returns a Tcl list of all resource types (see
95 RESOURCE TYPES below) found in the resource file pointed to by
96 resourceRef. If resourceRef is not specified it will return all
97 the resource types found in every resource file currently opened
98 by the application.
99
100 resource write ?options? resourceType data
101 This command will write the passed in data as a new resource of
102 type resourceType (see RESOURCE TYPES below). Several options
103 are available that describe where and how the resource is
104 stored.
105
106 -id resourceId
107 If the -id option is given the id resourceId (see
108 RESOURCE IDS below) is used for the new resource, other‐
109 wise a unique id will be generated that will not conflict
110 with any existing resource. However, the id must be a
111 number - to specify a name use the -name option.
112
113 -name resourceName
114 If -name is specified the resource will be named
115 resourceName, otherwise it will have the empty string as
116 the name.
117
118 -file resourceRef
119 If the -file option is specified then the resource will
120 be written in the file pointed to by resourceRef, other‐
121 wise the most recently open resource will be used.
122
123 -force If the target resource already exists, then by default
124 Tcl will not overwrite it, but raise an error instead.
125 Use the -force flag to force overwriting the extant
126 resource.
127
128
130 Resource types are defined as a four character string that is then
131 mapped to an underlying id. For example, TEXT refers to the Macintosh
132 resource type for text. The type STR# is a list of counted strings.
133 All Macintosh resources must be of some type. See Macintosh documenta‐
134 tion for a more complete list of resource types that are commonly used.
135
136
138 For this command the notion of a resource id actually refers to two
139 ideas in Macintosh resources. Every place you can use a resource Id
140 you can use either the resource name or a resource number. Names are
141 always searched or returned in preference to numbers. For example, the
142 resource list command will return names if they exist or numbers if the
143 name is NULL.
144
145
147 The resource command is only available on Macintosh.
148
149
151 open(n)
152
153
155 open, resource
156
157
158
159Tcl 8.0 resource(n)