• 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
Small change to script causes Script Editor to crash - Yosemite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small change to script causes Script Editor to crash - Yosemite


  • Subject: Small change to script causes Script Editor to crash - Yosemite
  • From: Lists <email@hidden>
  • Date: Sat, 25 Oct 2014 23:00:46 -0700

In this script, an example from the internet, I wanted to remove the display dialog section that allows renaming of the link created by the script. I commented out the portion of the script that allowed renaming the link and when I tested the script, Script Editor crashed and continued to crash every time I tried it. (!)

The commented out portion of the script was this block.

repeat
display dialog "Enter a title for the link:" default answer thisTitle
set thisTitle to the text returned of the result
if thisTitle is not "" then exit repeat
end repeat

The entire script, unchanged is:

tell application "Safari"
try
if not (exists document 1) then error "No document is open."
set theURL to URL of document 1
try
get theURL
on error
error "The front document has no URL."
end try
set thisTitle to name of document 1


--activate
end try
end tell
repeat
display dialog "Enter a title for the link:" default answer thisTitle
set thisTitle to the text returned of the result
if thisTitle is not "" then exit repeat
end repeat

tell application "Safari"
try
-- encode every character to unicode: &#4567;
repeat with i from 1 to the length of thisTitle
set thisID to the id of (character i of thisTitle)
if i is 1 then
set theTitle to "&#" & thisID & ";"
else
set theTitle to theTitle & "&#" & thisID & ";"
end if
end repeat


set startEcho to "echo "
set echoDelimiter to "'"


set html_1 to "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
  <html>
  <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
    <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">
    <title>"
set html_2 to "</title>
    <meta name=\"Generator\" content=\"Cocoa HTML Writer\">
    <meta name=\"CocoaVersion\" content=\"1038.11\">
      <style type=\"text/css\">
        p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
      </style>
    </head>
  <body>
  <p class=\"p1\"><a href="">
set html_3 to "\">"
set html_4 to "</a></p>
  </body>
  </html>"


set echoCommand to startEcho & echoDelimiter & html_1 & theTitle & html_2 & theURL & html_3 & theTitle & html_4 & echoDelimiter
set textutilCommand to " | textutil -convert rtf -inputencoding UTF-8 -format html -stdin -stdout"
set pbcopyCommand to " | pbcopy -Prefer rtf"


set entireCommand to echoCommand & textutilCommand & pbcopyCommand


do shell script entireCommand


set the target_file to the quoted form of the POSIX path of (((path to "ssnd") as string) & "Pop.aiff")
do shell script "afplay " & target_file


on error error_message
activate
display alert "Error Running Script" message error_message
end try
end tell

 _______________________________________________
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: Small change to script causes Script Editor to crash - Yosemite
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Trying To Script Magic Jack App
  • Next by Date: Re: Small change to script causes Script Editor to crash - Yosemite
  • Previous by thread: Trying To Script Magic Jack App
  • Next by thread: Re: Small change to script causes Script Editor to crash - Yosemite
  • Index(es):
    • Date
    • Thread