• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Broken script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Broken script


  • Subject: Re: Broken script
  • From: Mark J Reed <email@hidden>
  • Date: Thu, 28 Jul 2011 07:10:17 -0400

Why would you expect a script written for one app to work in another?  There's no standard API for text editors, or any other application category.  In general, a scripting dictionary has whatever the designers felt like putting into it, however they felt like doing so.   There are a few conventions that apply to most AppleScript applications - generic things, like accessing windows and documents - but other than that, anything goes.  So unless you find an editor whose scripting interface was specifically designed to be compatible with Tex-Edit's, I wouldn't expect any of your scripts to work.

Sent from my iPhone

On Jul 27, 2011, at 20:31, Robert Poland <email@hidden> wrote:

Hi,

I've been using this script since 2003. Now since Tex-Edit Plus is no longer supported with Lion, I'm trying to switch to another text editor.

This script errors in TextWrangler, Pages, TextEdit and Smile.

None of them seem to like "replace replacing with item x..." won't even compile.

I tried "Text Window 1" in TextWrangler.

Suggestions appreciated.

--script
on run
main()
end run

on main()
set DateString to current date
set DateString to date string of DateString
set AppleScript's text item delimiters to ","
set DateString to DateString's text items 2 thru 3 as text
set AppleScript's text item delimiters to ""
set index1Flag to false


tell application "Tex-Edit Plus"
if not (window 1 exists) then
beep
return
else
tell window 1
if (name of window 1) contains "index1.html" then set index1Flag to true


-- Initialize lists 
if not index1Flag then
set searchList to {"pictures/", "thumbs/", "JPG"}
set replaceList to {"/photo/pictures/", "/photo/thumbs/", "jpg"}
else
set searchList to {"pictures/", "thumbs/", "]PG"}
set replaceList to {"/photo/pictures1/", "/photo/thumbs1/", "jpg"}
end if
tell window 1
repeat with x from 1 to the number of items in replaceList
replace replacing with item x in replaceList looking for item x in searchList with cases matching and whole words matching
end repeat
-- html replacement string
replace looking for "<body>" replacing with "<body><center><h1 class=title>" & DateString & "</h1></center>"
replace looking for "<h1 class=title></h1>" replacing with ""
replace looking for "<td width=\"576\" colspan=\"3\" />" replacing with "<td width=\"576\" colspan=\"3\">"
replace looking for "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd" replacing with "http://www.w3.org/TR/html4/loose.dtd"
end tell
end tell


ignoring application responses
do shell script "say -v Alex " & "The replacing has ben completed. You should save the new file now."
-- say "The replacing has ben compleeted. You should save the new file now."
end ignoring


display dialog "Ok to save?" buttons {"OK", "No"} default button 1
if text of button returned of result = "No" then
return
else
tell application "Tex-Edit Plus" to activate
select window 1
tell application "Tex-Edit Plus" to close window 1 saving yes
end if
end if
end tell
return
end main

TIA,


Robert Poland - Fort Collins, CO


Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
  • Follow-Ups:
    • Re: Broken script
      • From: Robert Poland <email@hidden>
References: 
 >Broken script (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Batch update of properties of an object
  • Next by Date: Re: Broken script
  • Previous by thread: Re: Broken script
  • Next by thread: Re: Broken script
  • Index(es):
    • Date
    • Thread