• 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: preserving literal text in AppleScripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: preserving literal text in AppleScripts


  • Subject: Re: preserving literal text in AppleScripts
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 18 Dec 2006 10:56:10 -0800

On Dec 17, 2006, at 8:59 AM, Cameron Hayne wrote:

On 16-Dec-06, at 5:47 AM, Emmanuel wrote:

If you don't want to manually insert backslashes, why wouldn't you insert them automatically? You would use a scripting language, for instance AppleScript, why not (our programs work that way thousands of times a day.)

FYI, escaping an AS string is one instruction (uses Satimage.osax, but I'm sure plenty users can propose versions slightly longer which don't):

set s to "\"" & (change {"\\", "\""} into {"\\\\", "\\\""} in s) & "\""

The problem is that AppleScript makes it impossible to even define a string with backslashes (without escaping them manually).
E.g. the statement:
set pattern to "/^\s*foo"
is rejected.

What I believe Emmanuel is suggesting is that you write your string normally (i.e., without the escaping), and then -- without trying to compile it -- invoke a script that transmogrifies it into the properly escaped AppleScript version. You could make one that worked on the selection and altered it in place, or perhaps one that works on the clipboard contents, so you'd copy, invoke, paste. Smile has such a script already included.



--Chris Nebel AppleScript Engineering

_______________________________________________
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/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: preserving literal text in AppleScripts
      • From: Cameron Hayne <email@hidden>
References: 
 >preserving literal text in AppleScripts (From: Cameron Hayne <email@hidden>)
 >Re: preserving literal text in AppleScripts (From: Emmanuel <email@hidden>)
 >Re: preserving literal text in AppleScripts (From: Cameron Hayne <email@hidden>)

  • Prev by Date: Re: Picturebox to graphic box
  • Next by Date: Can't get every document file of every folder of startup disk whose creator type = "MSIE"
  • Previous by thread: Re: preserving literal text in AppleScripts
  • Next by thread: Re: preserving literal text in AppleScripts
  • Index(es):
    • Date
    • Thread