moving content of variable

Ben Rubinstein benr_mc at cogapp.com
Fri Dec 17 17:09:45 EST 2004


I've made some progress here.  You may not be able to do copy, set, or get
to Revolution (though I suspect you should be able to); but you can do "do
script" and "evaluate".

I think you ought to be able to do something along the lines of

    tell application "Revolution"
        evaluate "global gBlah; get gBlah"
        set x to the result
    end tell

and hence copy the value of a Rev global variable to a variable in
AppleScript.... but I've not managed to do so.  Perhaps I just haven't
stumbled upon the right way to approach it.

Nor have I been able to use the equivalent of my old HyperCard trick,
invoking a function or handler to set or get a value.  I think this may be
because the default stack in this instance is not necessarily the one you
first thought of.

So it seems - at least without further research - that you're limited to
built in functions, and/or expressions which permit specifying a particular
stack.

However, what I have been able to do is read custom properties.  This works:

    tell application "Revolution"
        evaluate "the uTempStorage of stack \"MyStack\""
        set x to the result
    end tell

So it is at least possible to move a complex string from Revolution to an
AppleScript variable.  (Presumably it would also be possible to refer to a
field in the same way.)

I've not yet established a way to move a complex value back.   It is of
course possible to move one complex value back, in that Rev can get the
result of invoking an AppleScript; however, if the AppleScript needs to
return multiple values, you might have to combine them with some delimiter.
But I think we have at least the basics, even if it's not very elegant.

It would certainly be preferable to able to use set/copy/get.

(BTW,, if you get into this, one gotcha you should be aware of: in
AppleScript, 'return' is the character with code 13 ('\r').  In Transcript,
it is the character with code 10 ('\n', linefeed).  I have come to accept
that this was a reasonable design decision; but what I still find insane is
that Transcript has introduced a new constant 'CR', which has the same
value.  (CRLF, on the other hand, has the value '\n\r').  There is no
constant that has the value '\r'.  You'll need to do something like "replace
return with numtochar(13) in x' on the way into AppleScript, and "replace
numtochar(13) with return in x" on the way out.)
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866



More information about the use-livecode mailing list