带Applescript的标题框

带Applescript的标题框,applescript,Applescript,我有一个字符串在标题的情况下,除了文章应该是小写。我想把文章改成小写。以下是我现在拥有的: set theStringTitleCase to "Iranian General Killed In Syria" set theListTitleCase to every word of theStringTitleCase set articles_in_title to {"in", "to", "at"} set fixed_words_in_title to {} repeat with

我有一个字符串在标题的情况下,除了文章应该是小写。我想把文章改成小写。以下是我现在拥有的:

set theStringTitleCase to "Iranian General Killed In Syria"
set theListTitleCase to every word of theStringTitleCase
set articles_in_title to {"in", "to", "at"}
set fixed_words_in_title to {}

repeat with the_word in theListTitleCase
    repeat with the_article in articles_in_title
        if the_word contains the_article then
            set the end of fixed_words_in_title to the_article
        else
            set the end of fixed_words_in_title to the_word
        end if 
    end repeat
end repeat

set theStringTitleCase to fixed_words_in_title as string

return theStringTitleCase

不知道我哪里出了问题

这应该可以解决问题

set theStringTitleCase to "Iranian General Killed In Syria"
set lowerCasedArticles to small_articles(theStringTitleCase)
log lowerCasedArticles
--> (*Iranian General Killed in Syria*)

to small_articles(aString)
    set capArticles to {" In ", " To ", " At "} # spaces are mandatory!
    set smallArticles to {" in ", " to ", " at "}
    # fail early conditions . . . 
    if (count capArticles) ≠ (count smallArticles) then error "unequal number of elements in lists "
    if aString is "" then return ""
    # we replace capitalized articles with lower cased ones below.
    tell (a reference to my text item delimiters)
        set tids to contents of it
        repeat with i from 1 to (count capArticles)
            set contents of it to item i of capArticles
            set oldlist to text items of aString
            set contents of it to item i of smallArticles
            set aString to oldlist as string
        end repeat
        set contents of it to tids
        return aString
    end tell
end small_articles