calling a RR script form Applescript

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

calling a RR script form Applescript

Post by mmiele » Thu Mar 08, 2007 6:07 pm

Opening the RunRev dictionary from Applescript editor, I found RunRev support the "do" and "Evaluate" command, to call an handler and to get a function result from Applescript.

I made a few tests but, while I was able to call commands like "open" or "quit", I wasn't able to call specific handlers in a stack.
Has someone an idea of how to do that?

Thanks.

P.S. I'm searching a way to make Director and Revolution talk. Other ideas different from Applescript?

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm

Post by xApple » Fri Mar 09, 2007 2:22 am

You can use Revolution to exectute AppleScript commands.
Look at the "do" command in the documentation.

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Fri Mar 09, 2007 3:06 am

What I need is just the opposite:using Applescript to execute a RR handler

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Contact:

Post by Obleo » Fri Mar 09, 2007 10:17 am

Wonder if you try using apple events. Revolution supports apple events
Apple scripts .sdef files show that most all scripts have an aevt code.

I would assume that you could set a revolution standalone to be scriptable by use of apple event codes and build a sdef file for use with apple script. I only have tried it with cocoa but I can't see why it wouldn't work with revolution with a little tinkering around.

:idea: Your question interest me to try it.

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Fri Mar 09, 2007 11:30 am

Revolution support two Applescript command: Do script and Evaluate.
Do script executes any RR script, Evaluates returns a RR function value.

Code: Select all

Tell "Revolution"
  do "quit"
end tell
works without problems.
But

Code: Select all

Tell "Revolution"
  do script "myScript" of stack "test"
end tell
or also

Code: Select all

Tell "Revolution"
  do script "\"myScript\" of stack \"test\""
end tell
doesn't do anything.
So I guess what is the right way to use "do script"[/code]

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Fri Mar 09, 2007 12:28 pm

Hi mmiele,

it may be that you have to use proper runrev do syntax. Check out the docs:

Code: Select all

do "go next card"
do "put" && x && "into myVar" & x -- might become "put 3 into myVar3"
do "select" && line 3 of field "Objects"
do "send myhandler to stack myStack"

Lynn P.
Posts: 79
Joined: Sun Apr 09, 2006 1:09 pm

Re: calling a RR script form Applescript

Post by Lynn P. » Fri Mar 09, 2007 2:49 pm

mmiele wrote: I'm searching a way to make Director and Revolution talk. Other ideas different from Applescript?
Hi mmiele ~
Can you give a simple example of what you want Director to communicate to a Rev stack? I'm not familiar with Director's Lingo syntax. Is this a two way communication? Do you need to send feedback back to Director?

I'm far from an expert on Rev like some on this forum and I may be way off here on what exactly you want to do but...
It could be you need to put what you want to send from Director into a text file, then read the text file into a variable in your Rev stack, then translate that into a workable Rev script.

Lynn P.

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Fri Mar 09, 2007 6:32 pm

Dear friends,
the "do" is a RR command: you can only use it from the inside of RR, eventually to control another application using Applescript.

What I need is just the opposite: to control RR trough Applescript from the outside of RR.

Every application which is "Applescript ready" responds to common commands ("new","open", "quit", etc.) and commands which are specific of the application.

The only specific commands to control RR trough Applescript, are "do script", to execute a RR handler, and "evaluate", to get the result from a RR function (these are the only shown if you open the RR dictionary from the inside of the Applescript editor).
As you can imagine, these are enough to do almost everything.

But the Applescript dictionary doesn't give the syntax of these two commands and I wasn't able to find it anywhere.

Lynn P.
Posts: 79
Joined: Sun Apr 09, 2006 1:09 pm

Post by Lynn P. » Fri Mar 09, 2007 11:59 pm

Okee Dokee! I only used the do script, not evaluate yet, but this is the syntax I used:
I put this in my stack's stack script:

Code: Select all

on myScript
  answer "I hear you AppleScript!" with "OK"
end myScript
and put this in AppleScript:

Code: Select all

tell application "Revolution"
	activate
	do script ("myScript")
end tell 
Is this what you were looking for? :-)

Lynn P.

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Mon Mar 12, 2007 10:32 am

Dear Lynn,

Code: Select all

do script ("myScript")
doesn't work on my system, but I've found a way:

Code: Select all

tell application "Revolution"
	activate
	do script "send \"myScript\" to stack \"myStack\""
end tell
But now I have another problem: if I close the stack in a standalone named "myApp",

Code: Select all

tell application "myApp"
	activate
	do script "send \"myScript\" to stack \"myStack\""
end tell
doesn't compile as a script.
The Applescript editor doesn't see "myApp" as a scriptable application.

Maybe I should include something when I save the stack as a standalone?

Lynn P.
Posts: 79
Joined: Sun Apr 09, 2006 1:09 pm

Post by Lynn P. » Tue Mar 13, 2007 4:22 am

mmiele wrote: But now I have another problem: if I close the stack in a standalone named "myApp",

Code: Select all

tell application "myApp"
	activate
	do script "send "myScript" to stack "myStack""
end tell
doesn't compile as a script.
The Applescript editor doesn't see "myApp" as a scriptable application.

Maybe I should include something when I save the stack as a standalone?
``````````````````
Go into your apps bundle by holding down the Control key while clicking on your app.
Choose Show Package Contents from the resulting menu.
Navigate to the folder Contents->Resources
Change the name of the file "Revolution.rsrc" to your apps name such as "MyApp.rsrc".
It should work after that. :-)

Lynn P.

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Tue Mar 13, 2007 11:04 am

IT WORKS!

Thank you: I should never find the solution by myself.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Fri Mar 16, 2007 4:59 am

Most features of runrev are very well hidden. You probably will get used to it after two or three years.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

keenethery
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2
Joined: Mon Aug 27, 2007 9:33 pm
Contact:

Can you add this info to the documentation?

Post by keenethery » Sun Mar 23, 2008 12:10 am

I've been searching off and on for this answer for over 2 years. It would be really handy if the docs showed:
1. the applescript that you would put into ScriptEditor to send and receive info via AppleEvents from a RunRev app.
2. a stack script catches the appleevent, reads data from a text field and replies to the appleevent with that info.
3. Plus, highlight that the .rsrc file name has to be changed for the app to accept AppleEvents.

The existing 2.8.1 docs only show a small part of the solution. Enough to make you think it works but not enough to get it to work. Documentation plus a sample stack / app and ScriptEditor script would be very helpful.

Thanks, Kee Nethery

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Can you add this info to the documentation?

Post by Mark » Sun Mar 23, 2008 12:22 am

keenethery wrote:I've been searching off and on for this answer for over 2 years.
It has been mentioned on the use list, for example here:
http://article.gmane.org/gmane.comp.ide ... pplescript

Nonetheless, I agree that the docs should include this kind of information.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply