• 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
Broken script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Broken script


  • Subject: Broken script
  • From: Robert Poland <email@hidden>
  • Date: Wed, 27 Jul 2011 18:31:18 -0600

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: Mark J Reed <email@hidden>
    • Re: Broken script
      • From: KOENIG Yvan <email@hidden>
  • Prev by Date: Re: Lion speaks 22 languages?
  • Next by Date: Batch update of properties of an object
  • Previous by thread: Re: Lion speaks 22 languages?
  • Next by thread: Re: Broken script
  • Index(es):
    • Date
    • Thread