Re: Strange text item delimiter effect
Re: Strange text item delimiter effect
- Subject: Re: Strange text item delimiter effect
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 03 Dec 2002 20:16:10 -0800
On 12/3/02 7:47 PM, "Jeffrey Mattox" <email@hidden> wrote:
>
The last line of code below gives different results depending on
>
whether the value of text item delimiters is "" or return. My
>
AppleScript book clearly says that the TID setting only affects text
>
items, not characters, words or paragraphs.
>
>
set outText to ""
>
set someStuff to (paragraphs 2 through 100 of theInputText)
>
set AppleScript's text item delimiters to return
>
set outText to outText & someStuff
>
>
Commenting out the setting TID line gives different results (the
>
lines in outTest appear mushed together).
>
>
So, how is that line affected by the setting of TID?
>
>
I'm using AppleScript Studio 2.0.1 and OS X 10.2.1, if that matters.
No, it applies in all versions of AppleScript, forever. That's precisely
what TIDs are used for - that's their purpose.
(paragraphs 2 thru 100 if theInputText)
is a list of 99 items. Did you think it was a single string, like
theInputText? No it isn't. 'paragraphs' is plural form of paragraph, and
each paragraph is an element of the text you gather them from. That's just
the same as a list of text items - in fact it IS a list of text items,
precisely. Whenever you coerce a list of text items to a string, AppleScript
inserts the current text item delimiter between the text items, so that's
exactly what it's doing here. What did you expect it to do?
You must _always_ set TIDs before coercing a list to text. And it's a good
idea to always reset them afterwards to {""}, the default, or to whatever
they were before you changed them.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.