Re: strings and strings (was Don't get it.)
Re: strings and strings (was Don't get it.)
- Subject: Re: strings and strings (was Don't get it.)
- From: Sander Tekelenburg <email@hidden>
- Date: Thu, 14 Dec 2006 05:36:35 +0100
At 18:35 -0800 UTC, on 2006-12-13, Todd Geist wrote:
> I have a variable called "my_string". It is a list of one item of
> class utxt.
Strange variable name then ;)
> if I push it through text Wrangler like so
>
> tell application "TextWrangler"
> set the text of document 1 to my_string
> set my_string to the text of document 1 as string
> end tell
>
> it comes out as TEXT and works great when I pass it to the
> AppleEventData.osax
>
> If however I just try to cast the variable as a String like so
>
> set my_string to my_string as string
>
> it still comes out as TEXT, But the OSAX doesn't like it.
What does "doesn't like it" mean?
> So the question is what is Text Wrangler doing to the string?
If I'm not mistaken it adds some formatting information.
I've forgotten the details, but IIRC a string can contain 'pure' characters,
or also additional formatting information. You can't see what you're dealing
with by just looking at the class. Usually the latter is the problem: people
use a trick of coercing to list and then coerce the first list item back to
string again, to drop the extraneous information. How to manipulate things in
the other direction in 'vanilla' AS I don't know.
Notice the different syntax colouring of the string "blah" in Script Editor's
Event Log:
set my_string to {"blah" as Unicode text}
log {my_string, class of my_string}
tell application "TextWrangler"
set the text of document 1 to my_string
set my_string to the text of document 1 as string
end tell
log {my_string, class of my_string}
set my_string to {"blah" as Unicode text}
log {my_string, class of my_string}
set my_string to my_string as string
log {my_string, class of my_string}
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden