Dear Peter,
I suggest you use a structure closer to this and avoid crowding everything into
the "using terms part".
using terms from application "BibDesk"
...
my Routine1(argument1, argument2)
...
end using terms from
on Routine1 (argument1, argument2)
... here you do other stuff possibly calling other routines
end Routine1
on Routine2(argument)
...
end Routine2
etc.
Regards,
Andreas
ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
[email protected]
www.sysecol.ethz.ch
+41 44 633-6090 phone
+41 44 633-1136 fax
+41 79 221-4657 mobile
Make it as simple as possible, but distrust it!
________________________________________________________________________
On 01/Apr/2010, at 23:29 , Peter Cowan wrote:
> On Thu, Apr 1, 2010 at 2:03 PM, Christiaan Hofman <[email protected]> wrote:
>>
>> On Apr 1, 2010, at 22:15, Peter Cowan wrote:
>>
>>> I'm using biblatex in the TeX preview window. And, since I often
>>> import directly from ISI using the Web of Science Search function, I
>>> get regular errors related to commas in the address or institution
>>> field. Perhaps there is a solution through biblatex to this problem,
>>> but I'm fine with either protecting or deleting the
>>> Address/Institution field on import.
>>>
>>> Script hooks seem like the perfect solution to this problem, but I am
>>> not an applescript users. I've tried to cobble something together
>>> based on the available example and got the following which doesn't
>>> appear to work, on import (from Web of Science) nothing happens no
>>> errors no braces. Any nudges in the right direction are appreciated.
>>>
>>> I apologize if this has been discussed on the list before, my searches
>>> did not reveal anything aside from confirmation of the biblatex TeX
>>> preview issue.
>>>
>>> Cheers
>>>
>>> Peter
>>>
> [snip old code]
>>
>> This won't work, because you call the external scripts outside the "perform
>> BibDesk action..." handler. The script hook will only call that handler, so
>> anything outside it (like defining the protectLib and errorLib) will be
>> ignored. Therefore reference to those external scripts will fail. You'll
>> have to move everything to inside the script hook handler.
>
> Christiaan,
>
> Thanks for the reply, I've moved the load script calls inside of the
> handler, but alas it still doesn't work. The current version is
> below.
>
> I apologize for being such an applescript newb, but is there a
> workflow you follow for developing this applescripts, e.g. debugging
> hints, setting "breakpoints" etc.
>
> Cheers
>
> Peter
>
>
> property theFieldToSet : "Address"
>
> using terms from application "BibDesk"
> on perform BibDesk action with publications thePubs for script hook
> theScriptHook
>
> set protectLib to (load script file ¬
> ((path to home folder as string) & "Library:Application
> Support:BibDesk:Scripts:Add Protect Strings.scpt"))
> -- load the Error Reporting script library
> set errorLib to (load script file ¬
> ((path to home folder as string) &
> "Library:ScriptingAdditions:Error Reporting.scpt"))
> -- we only report all errors at the end
>
> tell errorLib
> delayReportErrors()
> set its defaultErrorFileName to "BibDeskScriptErrors"
> end tell
>
> -- here you could return depending on theName or theField
> tell protectLib
> -- protect chars between balanced {}
> set its startProtectChar to "{"
> set its endProtectChar to "}"
>
> repeat with thePub in thePubs
>
> try
> tell thePub
> set curValue to value of field
> theFieldToSet
> -- generate a new value for the
> field
> set theField to field
> theFieldToSet
> set newValue to
> protectString(curValue)
> if newValue is not "{}" then ¬
> set value of theField
> to newValue
> end tell
>
> on error errorMessage number errorNumber
> tell errorLib to
> reportError(errorMessage, errorNumber)
>
> end try
>
> end repeat
> end tell --protectLib
>
> end perform BibDesk action with publications
> end using terms from
>
> -- see if we had any errors
> tell errorLib to checkForErrors()
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Bibdesk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users