[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript and MCL 2.0



>Hi:
>
>        I'm trying to get an applescript to talk to MCL 2.0, and would really
>appreciate any information from someone knowledgeable in this matter.
>
>        Suppose I startup MCL and then load the appleevents-toolkit and the
>eval-server. What is the syntax of the applescript statement(s) that would
>enable me to, say, (eval (+ 2 2))? In other words, I have an Applescript that
>says something like:
>
>tell application "MCL 2.0"
>     ?????
>end tell
>
>Please note that if I write an applescript such as the following:
>
>tell application "MCL 2.0"
>     quit
>end tell
>
>It does work properly, i.e. the MCL application quits.
>

Example 1
In the script editor:

set my-script to "(cons 'a '(b c))"
tell application "mcl 2.0" to do script my-script

Example 2
Now, dealing with strings is a bit confusing - say you want MCL to print
"Hello world".  You have to use an escape sequence to splice the string
correctly.  Here's how to deal with that:

set my-script to "(print " & (ASCII character of 34) & "Hello World" &
(ASCII character of 34) & ")"
tell application "mcl2.0" to do script my-script

Basically, just make the expression into a big string, (with embedded
strings if you like, e.g. example 2) and hand it to mcl.  No need to call
eval since it will read from the string and eval the form.

Hope this helps.  Don't forget to load eval-server or MCL won't understand
the do script command!


         Tom Bonura

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Apple Computer, Inc.   Advanced Technology Group,
        Interactive Media Lab
    Intelligent Systems Program
MS 301-3S, 1 Infinite Loop, Cupertino, CA 95104
Phone: (408)974-4538  Fax: (408)974-8414

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/