• 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
On the difficulties of "/"" in Applescript with example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On the difficulties of "/"" in Applescript with example


  • Subject: On the difficulties of "/"" in Applescript with example
  • From: Walter Bushell <email@hidden>
  • Date: Thu, 17 Oct 2013 10:30:32 -0400

Given the difficulties encountered in merely escaping quotes is it perhaps better to replace them with an arbitrary sequence, for example "!xyzzy!" and change them when it's time to actually use them. What happens with quotes is the slashes disappear in the course of normal use.

We have to use some method to handle this as we have no choice but to handle every string our (ab?)  users thrust upon us. I ran in this problem when presented with "Haydn: String Quartet In C, Op. 33/3, H 3/39, "Bird" - Allegro Moderato" which is illegal as an AppleScript construction. Perhaps fortunately as I would not have thought about that case, probably.
++++++++++++++++Code follows.
-- simple case works no quotes in file name
set x to POSIX file "/Users/Walter/Music/ur file"
tell application "Finder" to set B to name of file x
log B
log "+++++++++++++++++++++++++++"

-- merely once escaped  quotes fail
try
	set x to POSIX file "/Users/Walter/Music/\"ur\"file"
	log x
	tell application "Finder" to set B to name of file x
	--log {"B quoted= ", b}
on error erorrStr number errnum
	log {erorrStr, errnum}

end try
-- but passing an extra "\" does
try
	-- put in an extra (escaped \) and it runs
	set x to POSIX file "/Users/Walter/Music/\\\"ur\\\"file"
	log x
	tell application "Finder" to set B to name of file x
	log {"B quoted and extra Slashed= ", B}

on error erorrStr number errnum
	log {erorrStr, errnum}

end try
-----------------------Events & Replies ---------------------

--
"... the heavy people know some magic that can make things move and even fly,
 but they're not very bright, because they can't survive without their magic contrivances" -- Xixo, in "The Gods Must Be Crazy II"










 _______________________________________________
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:
    • ASEditor Drag&Drop
      • From: Luther Fuller <email@hidden>
    • Re: On the difficulties of "/"" in Applescript with example
      • From: "Manoah F. Adams" <email@hidden>
    • Re: On the difficulties of "/"" in Applescript with example
      • From: Shane Stanley <email@hidden>
    • Re: On the difficulties of "/"" in Applescript with example
      • From: Luther Fuller <email@hidden>
  • Prev by Date: Re: InDesign export slows to a crawl
  • Next by Date: Re: On the difficulties of "/"" in Applescript with example
  • Previous by thread: Re: Run script on a non-GUI user
  • Next by thread: Re: On the difficulties of "/"" in Applescript with example
  • Index(es):
    • Date
    • Thread