Some unexpected Automator behavior is baffling me. I’m hoping that smarter, more experienced scripters might help me figure out what is going on.
Running the following script, that shifts a text into uppercase, in AppleScript Editor,
set input to "abcabc"
return my uppercase(input)
to uppercase(text_to_process)
set lowercasestring to "abcdefghijklmnopqrstuvwxyzéèà òùìâêîôäëïöüæœãõáăȧéÃÄ©"
set uppercasestring to "ABCDEFGHIJKLMNOPQRSTUVWXYZÉÈÀÒÙÌÂÊÎÔÄËÃÖÜÆŒÃÕÃĂȦÉÃĨ"
set tid to text item delimiters
set text item delimiters to ""
repeat with loop from 1 to count lowercasestring
set the lower_letter to item loop of lowercasestring
set the text item delimiters to the lower_letter
set the character_list to the text items of the text_to_process
set the text item delimiters to item loop of the uppercasestring
set the text_to_process to the character_list as text
end repeat
set text item delimiters to tid
return the text_to_process
end uppercase
produces the result I expected: “ABCABC”
However, running the following similar script in Automator,
on run {input, parameters}
return my uppercase(input)
end run
to uppercase(text_to_process)
set lowercasestring to "abcdefghijklmnopqrstuvwxyzéèà òùìâêîôäëïöüæœãõáăȧéÃÄ©"
set uppercasestring to "ABCDEFGHIJKLMNOPQRSTUVWXYZÉÈÀÒÙÌÂÊÎÔÄËÃÖÜÆŒÃÕÃĂȦÉÃĨ"
set tid to text item delimiters
set text item delimiters to ""
repeat with loop from 1 to count lowercasestring
set the lower_letter to item loop of lowercasestring
set the text item delimiters to the lower_letter
set the character_list to the text items of the text_to_process
set the text item delimiters to item loop of the uppercasestring
set the text_to_process to the character_list as text
end repeat
set text item delimiters to tid
return the text_to_process
end uppercase
with the input “abcabc”, this Automator action produces the result “aBCaBC”, which I find baffling.
To add to the confusion, if I add two ‘do nothing’ lines to the script in Automator,
on run {input, parameters}
return my uppercase(input)
end run
to uppercase(text_to_process)
set lowercasestring to "abcdefghijklmnopqrstuvwxyzéèà òùìâêîôäëïöüæœãõáăȧéÃÄ©"
set uppercasestring to "ABCDEFGHIJKLMNOPQRSTUVWXYZÉÈÀÒÙÌÂÊÎÔÄËÃÖÜÆŒÃÕÃĂȦÉÃĨ"
set tid to text item delimiters
set text item delimiters to ""
set the character_list to the text items of the text_to_process -- DO NOTHING
set the text_to_process to the character_list as text -- DO NOTHING
repeat with loop from 1 to count lowercasestring
set the lower_letter to item loop of lowercasestring
set the text item delimiters to the lower_letter
set the character_list to the text items of the text_to_process
set the text item delimiters to item loop of the uppercasestring
set the text_to_process to the character_list as text
end repeat
set text item delimiters to tid
return the text_to_process
the script works, namely, the input “abcabc” produces the result “ABCABC”.
Can anyone figure out what is going on here?
Model: Macbook
AppleScript: 2.3?
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)