Re: Text without formatting (OS 9.1)
Re: Text without formatting (OS 9.1)
- Subject: Re: Text without formatting (OS 9.1)
- From: Nigel Garvey <email@hidden>
- Date: Fri, 2 Mar 2001 22:58:54 +0000
Richard 23 wrote on Fri, 2 Mar 2001 01:47:48 -0800:
>
Copy some styled text to the clipboard and run the following:
>
>
set theData to the clipboard
>
{the clipboard as record, theData as record}
>
>
--> {{string: "hello", styled Clipboard text: <<data styl0015...>>},
>
{<<class ktxt>>: "hello", <<class ksty>>: <<data styl0015...>>}}
>
>
I'm not sure why they're different, but string is "TEXT" and text is
>
"ctxt".
>
So I have always gone with the 4 character code method.
>
>
Although the little known "best type" property seems to agree with you
>
about "string" aka "TEXT".
I can't follow what you're saying here, Richard. If you're referring to
my earlier post, where I said that one should use 'as string' and not 'as
text' with 'the clipboard', my guess is that the difference is connected
with the fact that when 'as <whatever>' is is used with 'the clipboard',
it's a parameter - not an AppleScript coercion. (I suppose that Apple
lifted the code from Jon's Commands without adapting it to take 'as text'
the same way.) And it'll be the output from this command that creates the
difference between 'the clipboard as record' and 'theData as record'.
The default output (no parameter) seems to be 'as styled text'.
set the clipboard to "Fred"
the clipboard as record --> {string:"Fred"}
(the clipboard) as record --> {<<class ktxt>>:"Fred", <<class
ksty>>:<<data styl>>}
(the clipboard as styled text) as record --> ditto
Basically what I'm saying is the 'the clipboard' command has its own
peculiarities and you can't draw any conclusions about 'text' and
'string' from it.
>
set theData to the clipboard
>
set theText to <<class ktxt>> of (result as record)
>
return result's <<class pbst>> -- looks like Pabst...
>
--> string
>
>
As string and text are synonymous it shouldn't make any difference...
>
I just don't take any chances with it.
They're not always synonymous, even in AppleScript. 'Text' sometimes
means 'every string':
set theData to {bill:"Hello", fred:"Goodbye", string:"Doinnnggg!"}
string of theData --> "Doinnnggg!"
every string of theData --> {"Hello", "Goodbye", "Doinnnggg!"}
text of theData --> {"Hello", "Goodbye", "Doinnnggg!"}
<<class ctxt>> of theData --> compiles as 'text of theData', same result
NG