first, replaceChars needs to be "my replaceChars" - you have to tell AppleScript where to find the replaceChars routine (which needs to be in the same file as the below script).
So the full script (for you) should look like the below, assuming that you a)want to replace the url field and b)want it to pop up in the linked URLs as well as in the URL field. tell application "BibDesk" set theDoc to document 1 set thePubsSel to the selection of theDoc repeat with thePub in thePubsSel set theURL to the value of field "URL" of thePub if theURL contains "links.jstor.org" then set theURL2 to replaceChars(theURL, "links.jstor.org", "0- www.jstor.org.skyline.cudenver.edu") set the value of field "url" of thePub to theURL2 delete linked URL 1 of thePub make new linked URL with data theURL2 at end of linked URLs of thePub end if end repeat end tell on replaceChars(this_text, search_string, replacement_string) if this_text contains the search_string then set oldAStid to AppleScript's text item delimiters set AppleScript's text item delimiters to the search_string set the item_list to every text item of this_text set AppleScript's text item delimiters to the replacement_string set this_text to the item_list as string set AppleScript's text item delimiters to oldAStid end if return this_text end replaceChars On 2008-03-09, at 11:32 AM, Ingrid Giffin wrote: > I'm trying to write a script to change my JSTOR URLs to the proxy > version > that works for my school. It should copy the URL from the URL field, > change > the URL by a simple string substitution, and paste the result to the > My_Proxy_URL field. > > It seems to be working up until somewhere in the replaceChars step. > I'm sure > I'm just making some beginner's mistake. Here's my script: > > ------------- > > tell application "BibDesk" > set theDoc to document 1 > set thePubsSel to the selection of theDoc > repeat with thePub in thePubsSel > set theURL to the value of field "URL" of thePub > if theURL contains "links.jstor.org" then > set theURL2 to replaceChars(theURL, "links.jstor.org", > "0-www.jstor.org.skyline.cudenver.edu") > set My_Proxy_URL to theURL2 > end if > end repeat > end tell > ---------------- > > Here's the Event Log: > > > tell application "BibDesk" > get document 1 > document "Anthro Bib" > get selection of document "Anthro Bib" > {publication 8 of document "Anthro Bib"} > get value of field "URL" of publication 8 of document "Anthro Bib" > > "http://links.jstor.org/sici?sici=1558-8610%281972%2914%3Cii%3ATAOATH%3E2.0 > . > CO%3B2-P" > > replaceChars("http://links.jstor.org/sici?sici=1558-8610%281972%2914%3Cii%3A > TAOATH%3E2.0.CO%3B2-P", "links.jstor.org", > "0-www.jstor.org.skyline.cudenver.edu") > "BibDesk got an error: Can't continue replaceChars." > > ------------------------- > > Thanks for any suggestions. > --Ingrid Giffin > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Bibdesk-users mailing list > Bibdesk-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bibdesk-users > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bibdesk-users mailing list Bibdesk-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-users