代码之家  ›  专栏  ›  技术社区  ›  Bill

如何解决Applescript中的“内部表溢出”

  •  5
  • Bill  · 技术社区  · 15 年前

    当我试图加载itunesxml/plist文件时,我得到“internal table overflow”。在google之后,Applescript的内存似乎用完了。该文件的磁盘容量为18meg,因此,虽然从更大的方面来看,它仍然可以在2千兆位的Mac上运行。

    我如何解决这个问题?

    显然,由于它是由iTunes创建的,我无法控制它的生成。

    更新:相关片段:

    tell application "System Events"
        tell property list file (itunes_xml_file as string)
            tell contents
                set my_tracks to value of property list item "Tracks"
                repeat with t in items of my_tracks
    
    2 回复  |  直到 15 年前
        1
  •  2
  •   BastiBen    15 年前

    我想AppleScript并不是用来处理这么多数据的。我也曾尝试过使用AppleScript,并尝试做类似的事情(阅读iTunes库)。AppleScript的初衷是通过向应用程序发送AppleEvents来实现应用程序的自动化—这与AppleScript奇怪的语法结合在一起,会使许多简单的事情变得很难做。

    经过一段令人沮丧的时间后,我决定改用Python,因为它提供了一个读取plist文件的简单模块: http://docs.python.org/dev/library/plistlib.html

    可能不是您想听到的,但是AppleScript的问题是它很容易被数据重载,因为它所处理的数据的抽象相当庞大,并且占用大量内存。

    我敢肯定,如果您尝试一下Python,您将在不到一个小时内启动并运行一些东西。Python默认安装在所有mac上,而且非常容易学习。

        2
  •  1
  •   vike    12 年前

    更新: 有效性确认
    在最初写了下面的代码后,我试图还原手头的代码,但无法重现错误,并通过“删除”隐藏了帖子。
    刚才,在用 load script 调用,最初由运行处理程序处理,由CLI osascript(1)程序调用。这次它是可恢复的,我有信心取消“删除”它。

    简而言之,我的解决方案是改变 anyone_else's POSIX file path_posix AppleScript's POSIX file path_posix

    某种关系
    在写了下面的内容之后,我现在意识到我第一次只看到了“iTunes”,而忽略了与之相关的第一行 tell app "system events" property list file 也许/实际上/不知何故可能与我的问题有关 info for POSIX file .
    与操作/问题相关的注释:文件或别名 as string 提供一个冒号分隔的“HFS”路径。系统事件处理这两者。


    我有一个脚本 error "Internal table overflow." number -2707 从下面的街区。
    它是在我使用~IPC~调用块的处理程序时发出的( app app_name's handler_name() )(当我更彻底地调查它的时候,但是,我以前遇到过它——没有IPC)。

    try
        set file_modified_date to (info for my POSIX file file_path_posix)'s modification date
        true
    on error error_message number error_number from error_source partial result error_result to error_class
        if {error_number} is not in {-43, -37} then error error_message number error_number from error_source partial result error_result to error_class
        false
    end try
    

    A( (?)) 父级(用于 my current application (单独编译为“应用程序”和“单独运行”应用程序)


    改变

    set file_modified_date to (info for my POSIX file file_path_posix)'s modification date
    

    set file_modified_date to (info for AppleScript's POSIX file file_path_posix)'s modification date
    

    思想
    我猜不同的~modules~有不同的“表”(现在不用太多C)来处理像 POSIX文件 (打开“Scripting Addition”/extension(OSAX)“标准添加”,它(两者)仍然是,不是吗。

    围绕着摇篮

    杰出的~有[关于这个错误代码](http://lists.apple.com/archives/applescript-users/2005/Jul/msg00166.html)与一个相关但可能是其他来源(并提到他的库加载器)通过list.apple.com网站.

    cs.cmu.edu公司提供(120625)a pascal source from 1992 它定义了与本地/System/Library/Frameworks相同的限制/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/Headers/AppleScript.h
    最后是一个更为疏远的[大脚本问题](http://macscripter.net/viewtopic.php?id=11760)从 macscripter.net -一个关于applescript的知识和资源收集的好论坛。