Re: Item delimiters
Re: Item delimiters
- Subject: Re: Item delimiters
- From: John W Baxter <email@hidden>
- Date: Fri, 30 May 2003 23:07:30 -0700
- Envelope-to: email@hidden
At 8:37 -0700 5/30/2003, Michelle Steiner wrote:
>
On Friday, May 30, 2003, at 05:52 AM, Marcus Rodrigues wrote:
>
>
> Sorry about the newbie question, but: What are Item Delimiters? What
>
> they do?
>
>
I assume that you mean text item delimiters. The separate text (or a
>
string) into components. The default text item delimiter is a null
>
(i.e., "") which makes text items to be characters. So, for instance
>
the text items of "Hello" are "H", "e" "l" "l" and "o".
>
>
If you change the text item delimiter to anything else, the text items
>
will be substrings between the delimiters. For instance if the text
>
item delimiter is a space, then the text items will be (in general) the
>
words of the string. E.g, the text items of "Hi there my friend" would
>
be "Hi" "there" "my" and "friend" if the text item delimiter is a space.
>
>
If the text item delimiter is the letter e, then the text items of "Hi
>
there my friend" would be "Hi th" "r" " my fri" and "nd".
>
>
If the text item delimiter were the letter i, then the text items of
>
"Hi there my friend" would be "H" " there my fr" and "end".
>
>
When a script asks for text items of a string, the result is a list of
>
the text items; for example, the result from the previous paragraph
>
would be {"H", " there my fr", "end"}.
>
>
The reason the term is text item delimiters rather than text item
>
delimiter is that the specification allows for multiple delimiters,
>
specified in a list; e.g.:
>
>
set text item delimiters to {",", ".", ":", ";", "!", "?"}
>
>
However, Applescript's implementation uses only the first item of the
>
list, and ignores the rest; therefore, in practice, there can be only
>
one text item delimiter at a time.
Another thing that the text item delimiters do is glue list items together
into strings.
As a silly example (deliberately omitting putting back the pre-existing state):
set text item delimiters to {" jelly "}
set stuff to ["peach", "strawberry", "kiwi", ""]
display dialog stuff as string
[It's partly this usage that causes me to prefer the "put it back like it
was" style over the "set it before each use" style. It's easy to forget
that list-to-string is a use of the text item delimiters.]
--John
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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.