Does BTT recompile a script everytime it is called?

I use "Launch Application/Open File..." function to attach a custom AppleScript to a shortcut keys combination. I found that the property variables within the script can't retain their values. There is no such problem when the script is launched from Script Editor or Script Debugger.

It seems that the one possible reason is that BTT recompiles a script each time a script is being called. I wonder if that's the case. If so, is there any work around?

Thank you very much.

Only @Andreas_Hegenberg knows the detail.

As for the workaround, that depends on what type is the property variables, you can save it as BTT variables if it's (derived/calculated) strings or numbers; If it's reference (pointer), I cannot think of any way to hold the value.

Unfortunately the properties are pointing to objects/records of an app. Thanks a lot for the info!

BTT caches the scripts and usually doesn't recompile unless something changed in their code.
However I haven't found much documentation on how property variables are handled when scripts are being run through the Apple Script API. Did you find anything related? Maybe I could add some debug logs to figure out what's happening, do you have a concrete example?

Hi Andreas

Thank you for the info.

I use three different methods that can retain the properties: run script by script menu, by script debugger, and by running the script from the script folder of Devonthink Pro 3.5 (DT mechanism is to compile and load a script and cache it in memory - if being placed under its own script folder).

But when attaching the same script in BTT, the properties can't be retained. So I guess the most likely reason is that BTT recompiles the script each time a script is launched.

I verify the issue easily with running this simple script (saved as applet) by using "Launch Application ..." under different launch methods:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property theVar : 10
set theVar to text returned of (display dialog "" default answer theVar)

P.S. Launch the script from automator>services won't retain the properties, too. I search the web and it seems that's also a problem with the automator.

Thank you very much again!

Quick question: do the scripts work if you run them through the "Run Apple Script" predefined action?

If I use the "run script" button to test the script in BTT environment, the properties are not retained, too. Strangely, the assigned BTT shortcut won't invoke the script by this attachment method. I am not a very experience user of BTT (only for shortcuts!), so my method could be inappropriate.

It seems to work fine here if I assign it to a keyboard shortcut:

(The run script button will indeed always recompile, but triggering it through a shortcut should work)

You are using async background and I am using blocking. I have no idea on the difference.

Regardless, I am attaching the script applet to BTT, not saving the script in BTT config? That's why I use the "Launch application.." option.
Please correct me if I'm wrong.

Thanks again

Yes this was just a test to see whether it's working in general. (Background is usually better unless you need to wait for something before executing the next action)
The Run Apple Script action also allows to select a sctp file, however in that case it really recompiles. I'll fix that with the next update:

Thank you very much!

The latest alpha should now only recompile if the file has changed. (However only when using the "Run Apple Script" action)

Got it, thank you very much!