OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tcl/] [mac/] [AppleScript.html] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
<HTML>
2
 
3
<HEAD>
4
 
5
<TITLE>tclOSAScript -- OSA</TITLE>
6
 
7
</HEAD>
8
 
9
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF0000" ALINK="#00FF00">
10
 
11
<H2 ALIGN="CENTER">TclAppleScript Extension Command</H2>
12
 
13
<H3>NAME</H3>
14
<DL>
15
<DT>
16
AppleScript - Communicate with the AppleScript OSA component to run
17
        AppleScripts from Tcl.
18
</DL>
19
<H3>SYNOPSIS</H3>
20
<DL><DT>
21
<B>AppleScript <A NAME="compile">compile</A> </B><I>?-flag value?</I> <I>scriptData1
22
           ?ScriptData2 ...?</I><I>componentName</I>
23
<BR>
24
<B>AppleScript <A NAME="decompile">decompile</A></B> <I>scriptName</I>
25
<BR>
26
<B>AppleScript delete </B><I>scriptName</I>
27
<BR>
28
<B>AppleScript <A NAME="execute">execute</A> </B><I>?flags value?</I> <I>scriptData1
29
        ?scriptData2 ...?</I>
30
<BR>
31
<B>AppleScript <A NAME="info">info</A> </B><I>what</I>
32
<BR>
33
<B>AppleScript <A NAME="load">load</A></B> <I>?flag value? fileName</I>
34
<BR>
35
<B>AppleScript <A NAME="run">run</A></B> <I>?flag value?</I>
36
                    <I>scriptName</I>
37
<BR>
38
<B>AppleScript <A NAME="store">store</A></B> <I>?flag value? scriptName fileName</I>
39
<BR>
40
</DL>
41
 
42
<H3>DESCRIPTION</H3>
43
<DL>
44
<DT>
45
 
46
 
47
This command is used to communicate with the AppleScript OSA component.
48
You can <A HREF="#compile"><B>compile</B></A> scripts, <A
49
HREF="#run"><B>run</B></A> compiled scripts, <A
50
HREF="#execute"><B>execute</B></A> script data (i.e.  compile and run at a
51
blow).  You can get script data from a compiled script (<A
52
HREF="#decompile"><B>decompile</B></A> it), and you can <A
53
HREF="#load"><B>load</B></A> a compiled script from the scpt resource of a
54
file, or <A HREF="store"><B>store</B></A> one to a scpt resource.  You can
55
also get <A HREF="#info"><B>info</B></A> on the currently available scripts
56
and contexts.  It has the general form
57
 
58
<DL>
59
<DT>
60
<P>
61
<I>AppleScript option ?arg arg ...?</I>
62
<P>
63
</DL>
64
The possible sub-commands are:
65
<P>
66
<DL>
67
        <DT>
68
        <I>AppleScript</I> <A NAME="compile"><B>compile</A> </B><I>?-flag value?</I> <I>scriptData1
69
           ?ScriptData2 ...?</I>
70
        <BR>
71
 
72
        <DD>
73
        The scriptData
74
        elements are concatenated (with a space between each), and
75
        sent to AppleScript
76
        for compilation.  There is no limitation on the size of
77
        the scriptData, beyond the available memory of the Wish interpreter.
78
        <P>
79
        If the compilation is successful, then the command will return a token
80
        that you can pass to the <A HREF="#run">"run"</A> subcommand.  If the
81
        compilation fails, then the return value will be the error message from
82
        AppleScript, and the pertinent line of code, with an "_" to indicate
83
        the place where it thinks the error occured.
84
        <P>
85
        The
86
        compilation is controlled by flag value pairs.  The available flags
87
        are:
88
        <P>
89
        <DL>
90
                <DT>
91
                <A NAME="first compile switch"><B>-augment Boolean</B></A>
92
                <DD>
93
                To be used in concert with the <A HREF="#-context">-context</A> flag.
94
                If augment is yes,
95
                then the scriptData augments the handlers and data already in the
96
                script context.  If augment is no, then the scriptData replaces the
97
                data and handlers already in the context.  The default is yes.
98
                <P>
99
                <!-- I'm leaving this flag out for now, since I can't seem to get the
100
                     AE manager to obey it.  Even when I hard code the value, applications
101
                     still switch to the foreground.  Oh, well...
102
 
103
                <DT>
104
                <B>-canswitch Boolean  </B>
105
                <DD>
106
                 If yes, then applications activated by the code in scriptData will
107
                 be allowed to switch to the foreground.  If no, then they will use
108
                 the notification manager to indicate they need attention (this
109
                 usually means they blink the Finder icon, and put a check in the
110
                 application's entry in the Finder menu).
111
                 -->
112
 
113
                <DT>
114
                <B><A NAME="-context">-context</A> Boolean</B>
115
                <DD>
116
                This flag causes the code given in the scriptData to be compiled
117
                into a "context".  In AppleScript, this is the equivalent of creating an Tcl
118
                Namespace.  The command in this case returns the name of the context as
119
                the its result, rather than a compiled script name.
120
                <P>
121
                You can store data and procedures (aka
122
                handlers) in a script context.  Then later, you can
123
                run other scripts in this context, and they will see all the data and
124
                handlers that were set up with this command.  You do this by passing the
125
                name of this context to the -context flag of the run or execute subcommands.
126
                <P>
127
                Unlike the straight compile command, the code compiled into a
128
                script context is run immediatly, when it is compiled, to set up the context.
129
                <DT>
130
                <P>
131
                <B>-name string</B>
132
                <DD>
133
                Use <I>string</I> as the name of the script or script context.  If there is
134
                already a script
135
                of this name, it will be discarded.  The same is true with script
136
                contexts, unless the <I>-augment</I> flag is true.  If no name is provided, then a
137
                unique name will be created for you.
138
                <DT>
139
                <P>
140
                <B>-parent contextName  </B>
141
                <DD>
142
                This flag is also to be used in conjunction with the <A HREF="#-context">-context</A> flag.
143
                <I>contextName</I> must be the name of a compiled script context.  Then
144
                the new script context will inherit the data and handlers from the
145
                parent context.
146
        </DL>
147
        <P>
148
        <DT>
149
        <I>AppleScript</I> <B><A NAME="decompile">decompile</A></B> <I>scriptName</I>
150
        <BR>
151
        <DD>
152
        This decompiles the script data compiled into the script scriptName,
153
        and returns the source code.
154
        <P>
155
        <DT>
156
        <I>AppleScript</I> <B>delete </B><I>scriptName</I>
157
        <BR>
158
        <DD>
159
        This deletes the script data compiled into the script scriptName,
160
        and frees up all the resources associated with it.
161
        <P>
162
        <DT>
163
        <I>AppleScript</I> <B><A NAME="execute">execute</A> </B><I>?flags value?</I> <I>scriptData1
164
        ?scriptData2 ...?</I>
165
        <BR>
166
        <DD>
167
        This compiles and runs the script in scriptData (concatenating first), and
168
        returns the results of the script execution.  It is the same as doing
169
        <I>compile</I> and then <I>run</I>, except that the compiled script is
170
        immediately discarded.
171
   <P>
172
        <DT>
173
        <I>AppleScript</I> <B><A NAME="info">info</A> </B><I>what</I>
174
        <DD>
175
        This gives info on the connection.  The allowed values for "what" are:
176
        <P>
177
        <DL>
178
            <DT>
179
                <P>
180
            <B>contexts </B> <I>?pattern?</I>
181
            <DD>
182
            This gives the list of the script contexts that have been.
183
            If <I>pattern</I> is given, it only reports the contexts
184
            that match this pattern.
185
            <DT>
186
        <!--    <P>
187
            <B>language</B>
188
            <DD>
189
            Returns the language of this OSA component
190
            <DT>
191
        -->
192
                <P>
193
            <B>scripts</B> <I>?pattern?</I>
194
            <DD>
195
            This returns a list of the scripts that have been compiled in the
196
            current connection.  If <I>pattern</I> is given, it only reports the
197
            script names that match this pattern.
198
        </DL>
199
        <P>
200
        <DT>
201
        <I>AppleScript</I> <B><A NAME="load">load</A></B> <I>?flag value? fileName</I>
202
        <DD>
203
        This loads compiled script data from a resource of type 'scpt' in the
204
        file fileName, and returns a token for the script data.  As with the
205
        <I>compile</I> command, the script is not actually executed.  Note that all
206
        scripts compiled with Apple's "Script Editor" are stored as script
207
        contexts.  However, unlike with the "<I>compile -context</I>" command, the <I>load</I>
208
        command does not run these scripts automatically.  If you want to set up
209
        the handlers contained in the loaded script, you must run it manually.
210
        <P>
211
        <I>load</I> takes the following flags:
212
        <P>
213
        <DL>
214
            <DT>
215
            <B>-rsrcname string</B>
216
            <DD>
217
            load a named resource of type 'scpt' using the rsrcname
218
            flag.
219
            <DT>
220
                <P>
221
            <B>-rsrcid integer</B>
222
            <DD>
223
            load a resource by number with the rsrcid flag.
224
        </DL>
225
        <DD>
226
        <P>
227
        If neither the <I>rsrcname</I> nor the <I>rsrcid</I> flag is provided, then the load
228
        command defaults to -rsrcid = 128.  This is the resource in which
229
        Apple's Script Editor puts the script data when it writes out a
230
        compiled script.
231
        <P>
232
        <DT>
233
        <I>AppleScript</I> <B><A NAME="run">run</A></B> <I>?flag value?</I> <I>scriptName</I>
234
        <DD>
235
        This runs the script which was previously compiled into <I>scriptName</I>.  If the script
236
        runs successfully, the command returns the return value for this command,
237
        coerced to a text string.
238
        If there is an error in
239
        the script execution, then it returns the error result from the
240
        scripting component.  It accepts the following flag:
241
 
242
   <DL>
243
        <DT>
244
                <P>
245
                <B>-context contextName</B>
246
                <DD>
247
                <I>contextName</I> must be a context created by a previous call to <I>compile</I> with
248
                the -<I>context</I> flag set.  This flag causes the code given in the
249
                <I>scriptData</I> to be run in this "context".  It will see all the data and
250
                handlers that were set up previously.
251
   <!-- <DT>
252
                <B>-canswitch Boolean  </B>
253
                <DD>
254
                If yes, then applications activated by the code
255
                in scriptData will be allowed to switch to the foreground.  If no, then
256
                they will use the notification manager to indicate they need attention
257
                (this usually means they blink the Finder icon, and put a check in the
258
                application's entry in the Finder menu). -->
259
   </DL>
260
   <P>
261
        <DT>
262
        <I>AppleScript </I> <B> <A NAME="store">store</A></B> <I>?flag value? scriptName fileName</I>
263
        <DD>
264
        This stores a compiled script or script context into a resource of type 'scpt' in the
265
        file fileName.
266
        <P>
267
        store takes the following flags:
268
        <P>
269
        <DL>
270
            <DT>
271
            <B>-rsrcname string</B>
272
            <DD>
273
            store to a named resource of type 'scpt' using the rsrcname
274
            flag.
275
            <DT>
276
                <P>
277
            <B>-rsrcid integer</B>
278
            <DD>
279
            store to a numbered resource with the rsrcid flag.
280
        </DL>
281
        <P>
282
        <DD>
283
        If neither the rsrcname nor the rsrcid flag is provided, then the load
284
        command defaults to -rsrcid = 128.  Apple's Script Editor can read in files written by
285
        tclOSAScript with this setting of the <I>-rsrcid</I> flag.
286
</DL>
287
</DL>
288
<H2>Notes:</H2>
289
 
290
The AppleScript command is a stopgap command to fill the place of exec
291
    on the Mac.  It is not a supported command, and will likely change
292
    as we broaden it to allow communication with other OSA languages.
293
<H2>See Also:</H2>
294
 
295
 
296
</BODY>
297
 
298
</HTML>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.