Stupid, Stupid Text Features [Was: Can't set creator type]
Stupid, Stupid Text Features [Was: Can't set creator type]
- Subject: Stupid, Stupid Text Features [Was: Can't set creator type]
- From: Mr Tea <email@hidden>
- Date: Tue, 24 Feb 2004 10:46:43 +0000
In the original thread, I reported a problem in Panther when using the
text returned from a dialog to set the creator type or file type of a
file. Basically, it can't be done without first performing a really
hairy coercion.
Under Jaguar and earlier, this line...
set theCode to the text returned of dRes
...returned a result that could be used here...
tell application "Finder" to set creator type of f to theCode
...but in Panther, that second line causes a 'data not the expected
type' error.
And the data cannot by coerced into usable form with 'as text'
(Michelle Steiner's suggestion), 'as string', or by prepending '"" &'
to it. The correct method was suggested by Paul Berkowitz, and it
involves changing the first line to this...
set theCode to <<class ktxt>> of (text returned of dRes) as record
There. I said it was hairy. Paul is one of the most knowledgeable and
experienced contributors on this list, and it's his business to know
this kind of stuff, but what about the rest of us!!!???
If this kind of contortionism is required for such a simple procedure,
it suggests that AppleScript's text handling is all up the spout, and
makes a nonsense of this passage from Matt Neuberg's 'Definitive
Guide':
"Unicode text is basically indistinguishable from a string; the
differences between them are handled transparently. Whatever you can do
to a string, you can do to unicode text." (p 249)
Aside from setting creator and file types, are there any other places
where this gotcha is likely to strike?
Nick
pp Mr Tea
_______________________________________________
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.