(no subject)

Randall Lee Reetz randall at randallreetz.com
Tue Dec 11 13:44:56 EST 2007


Thanks Ken, i was using a custom prop and ran it as applescript.  Works fine.  What i still dont understand is why everything went unresponsive (the finder) and why it now works... Maddening. 
What might happen tomorrow?
-----Original Message-----
From: "Ken Ray" <kray at sonsothunder.com>
To: "How to use Revolution" <use-revolution at lists.runrev.com>
Sent: 12/11/2007 8:56 AM
Subject: Re: (no subject)

> Your AppleScript should look something like this:
> --3 lines, watch line wraps
> 
> tell application "Finder"
>    open folder "Macintosh HD:Users:MeUser:Desktop:myFolder"
> end tell
> 
> Your Rev script should look like this:
> --a do statement is single line so you'll need to unwrap this
> --the tricky bit is quotes and spaces in the right place
> 
> do "tell application " & quote & "Finder" & quote & cr & "open folder " &
> quote & "Macintosh HD:Users:MeUser:Desktop:myFolder" & quote & cr & "end
> tell" as applescript


Just FYI, there's a couple of other approaches (some are "best 
practices") when executing AppleScript from Rev... 

1) Put the script into a custom property or field and execute it 
(although I wouldn't recommend fields for a variety of reasons):

  do (the openFolderScript of this stack) as AppleScript

2) If you need to do it inline, use the \ line continuation feature to 
help make your code more readable:

  put "Macintosh HD:Users:MeUser:Desktop:myFolder" into tFolder
  put "tell application" && quote & "Finder" & quote & cr & \
    "open folder" && quote & tFolder & quote & cr & \
    "end tell" into tScript
  do tScript as AppleScript

3) Use backquotes (`) for quotation marks while building your script, 
then replace them with double quotes before you execute your script (a 
variation of #2 above is shown below):

  put "tell application`Finder` & cr & \
    "open folder `Macintosh HD:Users:MeUser:Desktop:myFolder`" & cr & \
    "end tell" into tScript
  replace "`" with quote in tScript
  do tScript as AppleScript

4) Use the format() function to put in quotes (\") and returns (\n) on 
the fly (be careful though as you can't use continuation chars with 
format IIRC):

  put format("tell application \"Finder\"\n") & \
    format("open folder \"Macintosh 
HD:Users:MeUser:Desktop:myFolder\"\n") & \
    "end tell" into tScript
  do tScript as AppleScript

Personally, I usually use #3 unless it's a one-liner, in which case I 
use #4 (if it's not too complex), but to each their own. :-)

Also with the upcoming Rev 2.9 having the ability to do "do ... as ... 
<scriptingLanguage>" supporting VBScript and JavaScript (on Windows), 
having a good way to handle other scripting languages is important, 
IMHO.


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list