Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: path to as string



Matt Neuburg wrote:

> >This is the subtle bit: the
> >AppleScript "string" type, despite many people's fervent belief to
> >the contrary, is *not* the same thing as typeText
>
>You said several things there that looked like you thought (or wanted me to
>think) they were totally normal and okay but which I actually found sort of
>bizarre and stunning.

I think Chris's point is that AppleScript types are not the same as Apple Event Manager types. Nor is there a one-to-one mapping between the two: AppleScript maps AEDescs of typeText, typeStyledText and typeIntlText to its 'string' type; AEDescs of typeInteger to either its 'integer' or 'real' type depending on its value (AS's integer type is only 30 bytes); and so on. AppleScript and AEM are not the same thing, despite what many folk think. And one shouldn't make unsafe assumptions about how AppleScript types represent data internally; these details are hidden for a reason. Sorta like class clusters in Foundation classes (NSNumber, NSString, etc) I guess.


>"string" and typeText are different? What can this mean? Does it mean that
>"string" and "text" are different? No;

'string's are from AppleScript, 'typeText's are from Apple Event Manager. 'text' is a semi-synonym for 'string' and also belongs to AppleScript.


>Or maybe typeText and 'TEXT' are different?

typeText = four_letter_code('TEXT'). No relation to AppleScript's 'text' keyword.


>I can see that the rtyp is 'TEXT'. So in that sentence, "string" does mean
>'TEXT'.

Nope, 'string' means 'string'. The internal implementation details are irrelevant.


>And then there's the part about using styled text to represent encoding
>information, as if this were the most natural thing in the world. Style is
>like bold, italic.

And font. Back in the bad old pre-Unicode days, users would rely on different fonts (e.g. Times/Helvetica, Symbol, Dingbats, etc.) to provide different glyphs for the same single-byte code point.  Nasty, but compared to workin' 28 hours-a-day down pit and bein' thrashed to an inch of our lives when we got 'ome, it were luxury.


>If a string can't be represented as pure text it
>would seem most natural for it to come back as Unicode text

You forget that AppleScript's string type predates not just its Unicode text type but the Unicode standard itself. FWIW, I think Apple made a mistake introducing a separate Unicode text type into AppleScript rather than continue to hide the niggly details behind a single unified 'string' type, but it's easy to say that in hindsight.


>- that's what
>the Finder does when you ask for the name of a file, for instance. I feel
>like I've walked into a hall of mirrors suddenly; I can't seem to get my
>bearings. And assuming I was thinking of explaining this to someone else, I
>really have no notion how I would do it.

AppleScript's 'string' type = legacy support. Don't use it unless you have to (e.g. when dealing with legacy apps). Use 'Unicode text' type instead. Besides, given all the bugs, lack of built-in functionality, etc. users need to deal with, this is probably the least of their worries.

has
-- 
http://freespace.virgin.net/hamish.sanderson/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.