Text Item Delimiter error
Text Item Delimiter error
- Subject: Text Item Delimiter error
- From: email@hidden
- Date: Sun, 18 Mar 2001 01:09:49 EST
I'm writing a search/replace handler and don't understand the results I'm
getting.
-----------------------
set someText to "_abcd_efg_hijk_lmnop_qrs_tuv_wx_yz_"
set thisSearch to "_"
set thisReplace to " "
--
--
set AppleScript's text item delimiters to thisSearch
set textItems to the text items in someText
--
*Case 1.a set searchedText to {}
*Case 2.a set searchedText to ""
repeat with iText from 1 to (count textItems)
set iTextItem to text item iText of someText
--
*Case 1.b set the end of searchedText to (iTextItem & thisReplace)
*Case 2.b set searchedText to (searchedText & iTextItem &
thisReplace)
end repeat
-----------------------
*Case 1.
searchedText is " _abcd _efg _hijk _lmnop _qrs _tuv _wx _yz _ "
--incorrect
*Case 2.
searchedText is " abcd efg hijk lmnop qrs tuv wx yz " --correct, but
----------
My first choice was Case 1, and I tried many variations of 'searchedText'
being a list but always got the same result. Won't Case 2.b start to eat up
memory when the text gets lengthy?