Speaking of "elaborate attemtps to work around this problem", there's this:
set aRecord to system info GetRecordLabels(aRecord) on GetRecordLabels(thisRecord) try get thisRecord as text on error errText set recordText to errText log errText end try set AppleScript's text item delimiters to ":\"" set labelParsingText to every text item of recordText set AppleScript's text item delimiters to return set labelParsingText to labelParsingText as string
set AppleScript's text item delimiters to "Can't make {" set labelParsingText to text item 2 of labelParsingText set AppleScript's text item delimiters to "," set recordLabels to {} set labelParsingText to paragraphs of labelParsingText set labelParsingText to the reverse of rest of reverse of labelParsingText repeat with thisLabel in labelParsingText set the end of recordLabels to the last text item of thisLabel as text end repeat
return recordLabels end GetRecordLabels
Doesn't do so well with some record values (aliases, for example, but where I needed it the values were all strings or lists of strings.
On 4/9/14 9:48 a.m., "Ed Stockly" <email@hidden> wrote:
Can you coerce this to a string,
Nope. Not possible.
Not directly. I believe that one of the cumbersome workarounds was to convert it to a script, then convert the script to text.
I'll see if I can find the script I did this with in Mac OS9. It was a printing script for Quark and the issue was that various print drivers would use different record labels for the same values, and that had to be resolved at runtime.
Also, I Mark's List & Record Tools Osax at Late Night Software could do this as well.
--get user property names {myAge:42} --> {"myAge"}
List & Record Tools | Late Night Software http://www.latenightsw.com/freeware/list-record-tools/
HTH
Ed
I know that it's difficult for some of you to accept that but English is not the unique language on the earth.
If I didn't use "Can't make {" as delimiter it's because this string is localized.
For instance, in French it is "Il est impossible de rendre {" and the end of the message is " } en type text."
So, I think that it's better to use this scheme to isolate the meaningful range of useful datas.
#[SCRIPT] system info try result as text on error errMsg number errNbr offset of "{" in errMsg set errMsg to text (result + 1) thru -1 of errMsg offset of "}" in (reverse of characters of errMsg) as text set errMsg to text 1 thru -(result + 1) of errMsg # Now we are free to use a more elaborate code if we want to treat possible encapsulated records set listOfRecords to my decoupe(errMsg, ", ") set theLabels to {} repeat with aRecord in listOfRecords item 1 of my decoupe(aRecord, ":") set end of theLabels to result end repeat theLabels end try
#=====
on decoupe(t, d) local oTIDs, l set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d} set l to text items of t set AppleScript's text item delimiters to oTIDs return l end decoupe
#===== #[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mercredi 9 avril 2014 20:40:33
|