Re: Apple Mail, HTML messages and text 1 VS character 1
Re: Apple Mail, HTML messages and text 1 VS character 1
- Subject: Re: Apple Mail, HTML messages and text 1 VS character 1
- From: "Nigel Garvey" <email@hidden>
- Date: Sun, 8 Jul 2007 23:02:43 +0100
Joe wrote on Sun, 8 Jul 2007 11:14:19 -0700:
>Another question I have is about how "text 1" returns different
>results depending on text type. The following two little scripts
>demonstrate.
>
><this fails>
>
>set a to "? this is a test"
>set b to text 1 of a
>-->Can't get text 1 of "? this is a test".
>
>if I had substituted (set b to character 1 of a) in the second line
>it would have worked
That's because 'character 1' is the correct term for the element you want
to extract from the text. 'Text 1' is only correct when getting the first
text (ie. string) from a list that contains at least one string:
set b to text 1 of {1, 2, "aardvark", "banana"}
--> "aardvark"
You can use 'text' in _range_ references with both lists and text. In one
case, you're getting a range from a list; in the other, a range from a
text. But to get an individual character from a text, you should 'character'.
><this works>
>
>set a to "? this is a test"
>set a to a as Unicode text
>--set b to text 1 of a
>-->"?"
It happens to produce the result you're expecting, but that's probably
more incidental than by design. 'Character' is still the correct term to
use, even with Unicode text. It also makes it clearer to human readers
what's intended.
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden