只是一個簡單的問題:以下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
謝謝!這就像一個魅力! –
要接受它,請點擊我答案旁邊的複選標記。 – fireshadow52