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

Re: Text Item Delimiter error


  • Subject: Re: Text Item Delimiter error
  • From: JollyRoger <email@hidden>
  • Date: Sun, 18 Mar 2001 13:24:09 -0600

on 3/18/2001 12:09 AM, email@hidden at email@hidden wrote:

> I'm writing a search/replace handler and don't understand the results I'm
> getting.

(snip)

Why re-invent the wheel, though? Here's a perfectly good search & replace
handler I've been using for years:

on MungerString(searchStr, replaceStr, sourceStr)
-- replace <searchStr> with <replaceStr> in <sourceStr>
try
set searchStr to (searchStr as text)
set replaceStr to (replaceStr as text)
set sourceStr to (sourceStr as text)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchStr)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceStr)
set theString to theList as string
set AppleScript's text item delimiters to oldDelims
return theString
on error errmsg
display dialog "MungerString() failed: " & errmsg
end try
end MungerString

Enjoy.

JR


References: 
 >Text Item Delimiter error (From: email@hidden)

  • Prev by Date: Re: Text Item Delimiter error
  • Next by Date: Repeat-Handler-Cancel
  • Previous by thread: Re: Text Item Delimiter error
  • Next by thread: Excel - export to html
  • Index(es):
    • Date
    • Thread