• 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: Write an antislash (backslash) in a variable ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write an antislash (backslash) in a variable ?


  • Subject: Re: Write an antislash (backslash) in a variable ?
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 12 Mar 2017 14:23:16 -0500

On Mar 12, 2017, at 08:12, emile.a.schwarz <email@hidden> wrote:
My first attempt to send this question returned to me because the list does not like the \ character in the subject line !


Hey Emile,

That's odd.

set TheReport to TheReport & "\cf0" # etc.: rejected

Of course.  The backslash is a reserved character.

Look in the Applescript Language Guide under “Special String Characters”.

Set RTFLead to "\" # Not rejected, but appears two times (\\) when used later…

This is a DISPLAY convention that represents the backslash.  In order to see it as a textual character rather than a special character you have to escape it with another backslash.

Character escaping confuses everyone who writes code from time to time – especially newbies.

If you examine the actual string in the variable unencumbered by the display conventions of an AppleScript editor you'll see it's really a plain old single backslash.

--------------------------------------------------
set TheReport to "sometext"
set TheReport to TheReport & "\\cf0"

tell application "TextEdit"
    activate
    make new document with properties {text:TheReport}
    tell text of front document
        set font to "Menlo"
        set size to 14
    end tell
end tell
--------------------------------------------------

You can also log the variable and look in the Script Editor's Log History window.

--------------------------------------------------
set TheReport to "sometext"
set TheReport to TheReport & "\\cf0"

log linefeed & TheReport & linefeed
--------------------------------------------------

I add the linefeeds, because I hate the block-comment bracketing.

--
Best Regards,
Chris

 _______________________________________________
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

References: 
 >Write an antislash (backslash) in a variable ? (From: "emile.a.schwarz" <email@hidden>)

  • Prev by Date: getting info about the selected even in Calendar
  • Next by Date: Re: Differences in output between AppleScript and Terminal
  • Previous by thread: Re: Write an antislash (backslash) in a variable ?
  • Next by thread: getting info about the selected even in Calendar
  • Index(es):
    • Date
    • Thread