只是一个简单的问题:以下 AppleScript 代码有什么问题?它应该做的是获取字符串中文本项(由用户提供的分隔符分隔)的位置。但到目前为止,它不起作用。脚本调试器简单地说,“无法继续 return_string_position”,没有任何具体错误。关于有什么问题的任何想法?
tell application "System Events"
set the_text to "The quick brown fox jumps over the lazy dog"
set word_index to return_string_position("jumps", the_text, " ")
end tell
on return_string_position(this_item, this_str, delims)
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
set this_list to this_str as list
repeat with i from 1 to the count of this_list
if item i of this_list is equal to this_item then return i
end repeat
set AppleScript's text item delimiters to old_delims
end return_string_position