Is restoring text item delimiters necessary?

前端 未结 3 1028
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 11:52

The commonly recommended way to use text item delimiters is like this:

set tid to AppleScript\'s text item delimiters
set AppleScript\'s text item delimiters         


        
相关标签:
3条回答
  • 2020-12-21 12:01

    If you run a script application, then I guess technically it is not necessary to rest them, because once it has quit, it has quit!

    But if you are running the script in Script Editor, then the changes to delimiters will stay in that script in the script editor. I've just seen that today.

    But what changed some years back is that it does NOT affect other scripts / windows open in Script Editor.

    Also, when running as an application, it only affects that particular script.

    0 讨论(0)
  • 2020-12-21 12:12

    I found this tidbit on https://developer.apple.com/library/mac/#documentation/applescript/conceptual/applescriptlangguide/conceptual/ASLR_fundamentals.html in the section AppleScript Fundamentals > Global Constants in AppleScript > text item delimiters:


    If you change the text item delimiters property in Script Editor, it remains changed until you restore its previous value or until you quit Script Editor and launch it again. If you change text item delimiters in a script application, it remains changed in that application until you restore its previous value or until the script application quits; however, the delimiters are not changed in Script Editor or in other script applications you run.


    0 讨论(0)
  • 2020-12-21 12:14

    I remember reading something about this change that you're talking about, that it was no longer necessary to reset them, however I couldn't find anything about it after a Google search. As such I did a quick test. I made these 2 scripts and ran them in AppleScript Editor. First this one...

    set text item delimiters to "something"
    return text item delimiters
    

    And then this one...

    return text item delimiters
    

    The second script returns {""}. So it seems the first script is not affecting the second. I tested this in both 10.6 and 10.8 with the same results.

    Here's applescript release notes. I can't find release notes for 10.7 or 10.8. Searching them turns up nothing on this subject either...

    http://developer.apple.com/library/mac/#releasenotes/AppleScript/RN-AppleScript/RN-10_3/RN-10_3.html#//apple_ref/doc/uid/TP40000982-CH103-SW1
    

    Therefore I have no definitive answer for you. Everyone says to reset them but my simple test shows that it's not required.

    Also you're right, you don't need "Applescript's" outside of tell blocks.

    0 讨论(0)
提交回复
热议问题