I noticed some odd behaviour when copying some code from ScriptEditor to a Run Applescript action in Automator.
This example code runs fine in Scripteditor :
When copied to the Run Applescript action in Automator it changes into this when compiled :
The "of" between number and items is no longer bold and the "in" changed to of. When run it errors with the following message :
Syntax Error
No result was returned from some part of this expression.
The solution is to change the code to this :
Why does this happen? Can someone shed some light on this? Thanks.
This example code runs fine in Scripteditor :
Code:
set numberList to {"1", "2", "3"}
repeat with i from 1 to number of items in numberList
set this_item to item i of numberList
display dialog this_item giving up after 3
end repeat
When copied to the Run Applescript action in Automator it changes into this when compiled :
Code:
set numberList to {"1", "2", "3"}
repeat with i from 1 to number of items [COLOR="Red"]of[/COLOR] numberList
set this_item to item i of numberList
display dialog this_item giving up after 3
end repeat
The "of" between number and items is no longer bold and the "in" changed to of. When run it errors with the following message :
Syntax Error
No result was returned from some part of this expression.
The solution is to change the code to this :
Code:
set numberList to {"1", "2", "3"}
repeat with i from 1 to count of items of numberList
set this_item to item i of numberList
display dialog this_item giving up after 3
end repeat
Why does this happen? Can someone shed some light on this? Thanks.