• 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: Converting characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting characters


  • Subject: Re: Converting characters
  • From: Paul Berkowitz <email@hidden>
  • Date: Tue, 07 Aug 2001 12:39:19 -0700

On 8/7/01 12:22 PM, "Dave Fugiel" <email@hidden> wrote:

> I have several characters that applescript
> does not like:
>
> " and \

Since " is used for specifying text in AppleScript, it cannot also be used
for itself. To get it in AS, you must precede it with the 'escape character'
\ . That is, to get a ", write \".

Therefore, \ can't be used for itself, since it's now used as an escape
character! To get it as itself, precede it also with another \. That is, to
get \, write \\.

>
> Can someone give me an idea how to do
> the following.
>

> if thechar ="X"
> set newchar to "\"
> else if thechar ="Z"
> set newchar to """
> end if

if thechar = "X" then
set newchar to "\\"
else if thechar = "Z" then
set newchar to "\""
end if


I hope you realize that this will also apply to lower-case versions "x" and
"z". If that's what you want, or you never expect to get the lower-case
versions, leave your script as it is. Otherwise, you have two options:

considering case
if thechar = "X" then
set newchar to "\\"
else if thechar = "Z" then
set newchar to "\""
end if
end considering


or else use the ASCII character definitions to be specific:

if thechar = ASCII character 88 then --upper-case "X"
set newchar to "\\"
else if thechar = ASCII character 90 then --upper-case "Z"
set newchar to "\""
end if




--
Paul Berkowitz


References: 
 >Converting characters (From: Dave Fugiel <email@hidden>)

  • Prev by Date: Converting characters
  • Next by Date: archives-it can't be as bad as I think it is
  • Previous by thread: Converting characters
  • Next by thread: Re: Converting characters
  • Index(es):
    • Date
    • Thread