Page 1 of 2

calling a RR script form Applescript

Posted: Thu Mar 08, 2007 6:07 pm
by mmiele
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?

Posted: Fri Mar 09, 2007 2:22 am
by xApple
You can use Revolution to exectute AppleScript commands.
Look at the "do" command in the documentation.

Posted: Fri Mar 09, 2007 3:06 am
by mmiele
What I need is just the opposite:using Applescript to execute a RR handler

Posted: Fri Mar 09, 2007 10:17 am
by Obleo
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.

Posted: Fri Mar 09, 2007 11:30 am
by mmiele
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]

Posted: Fri Mar 09, 2007 12:28 pm
by marielle
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"

Re: calling a RR script form Applescript

Posted: Fri Mar 09, 2007 2:49 pm
by Lynn P.
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.

Posted: Fri Mar 09, 2007 6:32 pm
by mmiele
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.

Posted: Fri Mar 09, 2007 11:59 pm
by Lynn P.
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.

Posted: Mon Mar 12, 2007 10:32 am
by mmiele
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?

Posted: Tue Mar 13, 2007 4:22 am
by Lynn P.
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.

Posted: Tue Mar 13, 2007 11:04 am
by mmiele
IT WORKS!

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

Posted: Fri Mar 16, 2007 4:59 am
by BvG
Most features of runrev are very well hidden. You probably will get used to it after two or three years.

Can you add this info to the documentation?

Posted: Sun Mar 23, 2008 12:10 am
by keenethery
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

Re: Can you add this info to the documentation?

Posted: Sun Mar 23, 2008 12:22 am
by Mark
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