如何解决“无法继续计数”的问题处理参数的 AppleScript 应用程序中出现问题?

发布于 2024-09-11 11:10:01 字数 443 浏览 2 评论 0原文

我正在尝试在网上找到的一个简单的 AppleScript:

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

我将其保存为应用程序。每次我从 Finder 中双击它时,都会弹出以下错误消息:

无法继续计数

我似乎找不到任何方法来解决这个问题。

运行 Mac OS X Snow Leopard 10.6.4。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱影子 2024-09-18 11:10:01

当您双击它时,您没有传递任何参数,因此没有什么可计算的......所以它会出错。您可以使用 try 块来解决错误。试试这个...

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文