Puzzling Automator Script Behavior

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)

Hi,

the difference is:
In the first script input is an string
In the second script input is a list (of strings)

return my uppercase(item 1 of input)

should work

This does the same task with a shell script


on run {input, parameters}
	set theText to quoted form of item 1 of input
	return do shell script "/bin/echo -n " & theText & " | /usr/bin/tr a-z'éèà òùìâêîôäëïöüæœãõáăȧéíĩ' A-Z'ÉÈÀÒÙÌÂÊÎÔÄËÏÖÜÆŒÃÕÁĂȦÉÍĨ'"
end run

Thank you. That clear it up.

I have just been informed that my string is missing at least the following two characters “ÿ”, “ñ” and their uppercase versions “Ÿ”, “Ñ”. I notice that your shell script approach has trouble with the “ÿ”.

Does “ß” have an uppercase form?

No, normally ß will be replaced by SS