set {text item delimiters, newText} to {", ", (items of ml as text)}
. “,” and (items of ml as text) are both evaluated before either the text item delimiters or newText are set. So the coercion takes place before the delimiters are changed.
On the second run (unless the script’s recompiled in the meantime), the tids are still set from the first run.
By the way, (items of ml as text) creates another list containing the same items as ml and derives the text coercion from that, whereas it’s only necessary to derive the coercion from ml itself, as in (ml as text).
Just for the record, items of ml as text was something I tried to make it work on the first run, in my Applescript Editor, I have to run this code twice in order to make it work:
set ml to {"a", "b", "c"}
set {text item delimiters, newText} to {", ", ml as text}
log newText
It works on first attempt in Smile, but, I am not totally sure, if that is because I have run the code earlier there, and that there is a common scripting component.
And it’s probably worth pointing out that it’s not just TIDs, but any property of AppleScript. If, for example, a script contains the line set AppleScript’s return to “WTF” , any other scripts might start behaving more than a tad strangely. A more practical consideration is the new progress properties.
I tried something like that, in order to make a fast one liner, I tried to assign the text item delimiters to pi, but, it turns out that pi has become read only.
Thanks Shane, that was the correct solution to a bad idea, I oversaw that possibility, the other reason was of course, that I need an extra line to restore pi, or any other constant, -not sure if I think it is comforting that the constants aren’t read only after all though.
Ouch! I don’t recall ever seeing the advice that one should explicitly set ‘pi’, the time constants, the character constants, and AppleScript’s version before using them rather than assume they had their default values! :o
use framework "Foundation"
use framework "OSAKit"
set theInst to current application's OSALanguageInstance's languageInstanceWithLanguage:(current application's OSALanguage's defaultLanguage())
set theScript to current application's OSAScript's alloc()'s initWithSource:"{weeks, days, hours, seconds, minutes, pi, linefeed, return, quote, space, tab, text item delimiters, AppleScript's version}" fromURL:(missing value) languageInstance:theInst usingStorageOptions:0
set {weeks, days, hours, seconds, minutes, pi, linefeed, return, quote, space, tab, text item delimiters, AppleScript's version} to (theScript's executeAndReturnError:(missing value)) as list