The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Scripts which behave incorrectly when run from OF toolbar Thread Tools Search this Thread Display Modes
Some scripts behave in one way if run from the OmniFocus scripts menu, and another if run from the OmniFocus toolbar.

global variables, in particular, conserve their value between script runs if launched from the script menu, but lose their value if run from a toolbar icon.

This is a pity, as a lot of potentially useful script behaviours (various kinds of toggles, for example) are inaccessible if you want to use the toolbar.

Here is a simple example of a script which returns different results from menu and toolbar.

Try running it a few times from the menu, and then a few times from the toolbar ...

Code:
global gtest

try
	set gtest to gtest * 2
on error
	set gtest to 1
end try

display dialog "This time value is " & gtest as string
--

Last edited by RobTrew; 2010-06-11 at 12:19 AM..
 
Quote:
Originally Posted by RobTrew View Post
Some scripts behave in one way if run from the OmniFocus scripts menu, and another if run from the OmniFocus toolbar
The reason for this discrepancy would seem to be that:
  1. The OmniFocus script menu does save a compiled script file back to disk after the script runs (normal behaviour)
  2. The OmniFocus toolbar omits to do this (a pity)

As a temporary fix, the correct behaviour can be simulated from within the code, though it is a little cumbersome.

This version should work in the same way from the OF toolbar as it does from the OF script menu ...

Code:
set strPersist to (path to temporary items folder as string) & "Persistence.scpt"

script scrpRetainValue
	property numValue : 1
end script

try
	set scrpRetainValue to load script file strPersist
	set numValue of scrpRetainValue to (numValue of scrpRetainValue) * 2
on error
	set numValue of scrpRetainValue to 1
end try

display dialog "This time value is: " & (numValue of scrpRetainValue) as string

store script scrpRetainValue in file strPersist replacing yes
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running scripts from OF toolbar - limitations RobTrew OmniFocus Extras 2 2010-06-17 11:46 PM
Toolbar scripts: Move to Top/Bottom ptone OmniFocus Extras 4 2008-01-23 07:49 PM
Toolbar scripts don't store properties ptone OmniFocus Extras 1 2008-01-12 07:59 PM
Waiting Fors displaying incorrectly webbosoft OmniFocus 1 for Mac 8 2007-10-10 09:15 AM
Incorrectly-sized popup windows Handycam OmniWeb Bug Reports 1 2006-05-23 10:31 AM


All times are GMT -8. The time now is 07:37 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.