• 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: Keyboard Question?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyboard Question?


  • Subject: Re: Keyboard Question?
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 19 Jan 2001 18:43:08 -0800

On 1/19/01 8:31 AM, "Arthur J Knapp" <email@hidden> wrote:

> From time to time, I have had a need to have some portion of the Mac
> character set available to a script. When I need such a list/string, I
> find that it saves on runtime execution to create compile-time
> properties with the "run script" command:
>
>
> -- For large strings, it is often faster to avoid repeated
> -- operations involving the ASCII commands, so we use them
> -- only during compile.
> --
> property kControlChars : run script ,
> "set lst to {}
> repeat with i from 0 to 31
> set end of lst to ASCII character i
> end repeat
> return lst as string"
>
> on ZapControlChars(str)
>
> set str to characters of str -- listify
>
> repeat with c in str
>
> -- Since we are not using the ASCII commands, we have to
> -- be careful about AppleScript's comparison operations.
> --
> considering case, diacriticals, expansion, hyphens, punctuation and
> white space
> if (kControlChars contains c) then set c's contents to 0
> end considering
> end repeat
>
> return (plain text of str) as string
>
> end ZapControlChars
>
>
> ZapControlChars("Dude" & (ASCII character 5) & "Guy")
>


This is excellent, Arthur, but don't you need to make an exception for ASCII
character 13? Otherwise all your paragraphs will run together.

ZapControlChars("Dude.

Guy")
-- "Dude.Guy"

Maybe:

property kControlChars : run script ,
"set lst to {}
repeat with i from 0 to 31
if i/= 13 then set end of lst to ASCII character i
end repeat
return lst as string"


--
Paul Berkowitz


References: 
 >Re: Keyboard Question? (From: "Arthur J Knapp" <email@hidden>)

  • Prev by Date: Startup Disk and other oddities
  • Next by Date: Re: Startup Disk and other oddities
  • Previous by thread: Re: Keyboard Question?
  • Next by thread: Re: Keyboard Question?
  • Index(es):
    • Date
    • Thread