I'm trying out a simple AppleScript I found online:
on run argv
set rtn to ((count of argv) as text) & " parameters passed.
The parameters were:
"
repeat with arg in argv
set rtn to rtn & "开发者_开发问答 " & (arg as text) & "
"
end repeat
return rtn
end run
I saved it as an Application. Everytime I double click it from the Finder, I get the following error popup:
Can't continue count
I can't seem to find any way to solve this.
Running Mac OS X Snow Leopard 10.6.4.
When you double-click it you aren't passing any arguments so there's nothing to count... so it errors. You can get around errors with a try block. Try this...
on run argv
try
set rtn to ((count of argv) as text) & " parameters passed.
The parameters were:
"
repeat with arg in argv
set rtn to rtn & " " & (arg as text) & "
"
end repeat
on error
set rtn to "There are no arguments to count!"
display dialog rtn buttons {"OK"} default button 1 with icon note
end try
return rtn
end run
精彩评论