I’ve created a script to populate the ever popular DragThing application. I’ve come to a few limitations in the dictionary that I need to skirt around. Does anyone have any idea on how to turn the text of a reference (yes, i realize it’s not really text) into a string?
I’m not familiar with casting. Is that different than coercion? I don’t use references much. Do you mean something like this?
set var to “hi”
set varref to a reference to var
set var2 to text of varref
If coercing your reference produces an error, you could scrape the “text of the reference” from the error handler of a try block. It aint pretty though:
tell application "iTunes" to get selection
get_string from result
--> "«class cFlT» id 11446 of «class cUsP» id 11345 of «class cSrc» id 44 of application \"iTunes\""
run script result
--> file track id 11446 of user playlist id 11345 of source id 44
to get_string from a_reference
try
set reference_string to a_reference as string
on error error_message
set text item delimiters to "Can't make "
set reference_string to item 2 of text items of error_message
set text item delimiters to " into type string."
set reference_string to item 1 of text items of reference_string
set text item delimiters to ""
end try
return reference_string
end get_string