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

Re: Separating Text


  • Subject: Re: Separating Text
  • From: Mr Tea <email@hidden>
  • Date: Mon, 19 Nov 2001 16:32:35 +0000

This from JRyan - dated 19/11/01 12.55 am:

> My latest problem is setting my comment variable to only part of the
> comment text (only up to some special character)

If your 'special character' is used only once in the comment, this is a
doddle. You need to reset AppleScript's default text item delimiters...

A text item delimiter is that which separates one text item from the next.
Usually this is set to '"", which equates to the space that separates each
letter, a space which effectively contains nothing at all. (This is not the
same as the 'space' character that is used to separate words - that kind of
space is also a 'text item')

So, if you ask AppleScript to give you every text item of "Hello World", it
will return a list containing 11 individual strings, each containing one
letter or space character.

If your Finder comment is something like "Nice legs*shame about the face",
you could do something like this...

set myComment to "Nice legs*shame about the face"
copy AppleScript's text item delimiters to oldTIDs
set AppleScript's text item delimiters to "*"
copy text item 1 of myComment to partOne
copy text item 2 of myComment to partTwo
set AppleScript's text item delimiters to oldTIDs
display dialog partOne -- "Nice legs"
display dialog partTwo -- "shame about the face"

Note that the script resets the delimiters to their previous (default)
value. As I understand it, you should always do this when messing around
with the TIDs, otherwise BAD THINGS WILL HAPPEN!

HTH

Mr Tea
--


References: 
 >Separating Text (From: JRyan <email@hidden>)

  • Prev by Date: Re: Separating Text
  • Next by Date: Re: Scripting Default Folder's scripting addition
  • Previous by thread: Separating Text
  • Next by thread: Re: Separating Text
  • Index(es):
    • Date
    • Thread