[futurebasic] Re: [FB] C API Conversion

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

From: Alain Pastor <apastor@...>
Date: Wed, 16 Nov 2005 09:11:13 +0100
russp@... a écrit :

> 
> 2.  The inline applescript functions in FB are too slow.  I think this is
> because USR APPLESCRIPTRUN has to compile it before it can run.  The slowness
> is an issue only because it ties up the processor too much while its
> crunching the script (even a short one).
> 

Russ,

Usr AppleScriptRun is useful when you need to alter the code of the 
script with data computed by your prog. You can load and run a 
precompiled script using Usr AppleScriptLoadAndRun. The script can be 
located in an external file or in the resource fork of your app.

Usr AppleScriptLoadAndRun( 0, 128 ) runs a resource-based compiled script.
Usr AppleScriptLoadAndRun( scriptFSSpec, 0 ) runs an external script.

You must always use Usr AppleScriptGetResult after a script has been 
executed even if the script doesn't return a value in order to purge the 
internal AppleScript buffer of FB.

resultHandle = Usr AppleScriptGetResult
Long If resultHandle
   // do something with the data returned
   // don't forget to dispose of that handle too
End If

You must not expect too much better performances. AppleScript is slow in 
nature. Your prog can certainly slowdown the process, but the target 
application can as well. The system can be at fault when it is busy with 
other more important tasks to do, data must go back and forth, and I 
don't count the implementation of the AppleScript API that can change 
things dramatically in the speed area (that's my own experience).

Alain