Re: Write an antislash (backslash) in a variable ?
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 !
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.
|
_______________________________________________
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