[futurebasic] C API Conversion

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2005 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Thu, 17 Nov 2005 03:53:20 -0500
In this thread I put together a little tool to 
help me see what is going on with the more 
complex code russp has been wrestling with. This 
should launch an AppleScript file.

OSADoScriptFile is defined in the OSA.h header 
file and is supposed to be available in OS X 
10.3.+. However, upon launch I get a warning that 
OSADoScriptFile is not available on my computer 
(I'm running OS X 10.3.9 here at home). Any ideas 
why this isn't working? If you're running Tiger, 
would you mind testing it for me?

BTW: Here's a simple AppleScript that simply 
launches the AppleScript editor and can be made 
into a script to put on your Desktop for testing-:

tell application "Script Editor" to activate

Ken


// include "Subs AppleScript.Incl"
// include "Tlbx OSA.Incl"

toolbox fn OSADoScriptFile( ComponentInstance scriptingComponent,¬
                                         const FSRef * scriptFile,¬
                                                  OSAID contextID,¬
                                             DescType desiredType,¬
                                                   long modeFlags,¬
                                            AEDesc * resultingText ) = OSAError

_kOSAModeNeverInteract = _kAENeverInteract

local fn LaunchAppleScript
dim as FSSpec              @ fs
dim as FSRef               @ fsRef
dim as str255                fStr
dim as ComponentInstance     ci
dim as AEDesc              @ resultingText
dim as OSErr                 err

/* open the default scripting component */
ci = fn OpenDefaultComponent( _kOSAComponentType, _typeAppleScript )
long if ( ci != 0 )
fStr = Files$( _FSSpecOpenPreview,,"Open AppleScript...", fs)
long if ( fStr[0] )
err = fn FSpMakeFsRef( fs, fsRef )
long if ( err == _noErr )
err = fn OSADoScriptFile( ci,¬
                        fsRef,¬
              _kOSANullScript,¬
                    _typeChar,¬
       _kOSAModeNeverInteract,¬
                resultingText )
end if
end if
end if

end fn

fn LaunchAppleScript

do
handleevents
until 0