[futurebasic] Re: Running a FM script (Applescript question)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2004 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Fri, 27 Feb 2004 16:43:32 -0500
In this tread, Paul wrote:

>Thanks Ken, I have that part (I'm using RUN). I was wondering if I
>could perform an applescript (or do some kind of mystical apple events
>call to FM) right from FB thereby eliminating the "helper" compiled
>applescript that I am currently setting up.


Sorry, I thought you just wanted to launch your 
compiled AppleScript from with FB^3.

The following simple example shows how to run an 
AppleScript from inside FB. First, here is the 
raw AppleScript code (this should compile and run 
from within Script Editor. It creates a tiny app 
that when launched open's the user's default 
e-mail app to the included e-mail address):

set the_url to "contact@..."
tell application "Finder" to make new internet 
location file at desktop to the_url with 
properties {name:"Staz Software e-mail"}

And here is my FB^3 adaptation of the AppleScript 
into a stand-alone FB^3 function which allows the 
user to custom create a URL launcher to appear on 
the desktop:

Include "Subs AppleScript.Incl"

local fn MakeURLLauncher$( mailToAddr as str255,¬
                       launcherName as str255 )
dim as OSErr  err
dim as str255 result

route _toAppleScript
print "set the_url to """ + mailToAddr + """
print "tell application ""Finder"" to make new internet ¬
location file at desktop to the_url with properties ¬
{name:""" + launcherName + """}"
route _toScreen

err = usr AppleScriptRun( result )
long if (err != _noErr)
result = "error:" + str$( err )
result = str$( err )
end if

end fn = result

window 1

result = fn MakeURLLauncher$( "contact@...",¬
                                    "Staz Software e-mail" )

include "Subs Quick Event Loop.Incl"

Take the raw code of your AppleScript, put each 
line in double quotes prefixed with a print 
statement, and sandwich it between the route 
_toAppleScript and route _toScreen and let 'er 
run. (Be sure to add
Include "Subs AppleScript.Incl" to the  code.)

To unsubscribe, send ANY message to: futurebasic-unsubscribe@...