Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取项目信息时出现问题(applescript)_Applescript_Subroutine - Fatal编程技术网

获取项目信息时出现问题(applescript)

获取项目信息时出现问题(applescript),applescript,subroutine,Applescript,Subroutine,我是一个相当好的应用程序描述,并希望在此方面得到一些帮助。我正在制作一个类似于WindowsXP回收站的回收站应用程序。它当然是一滴。当我将项目放到应用程序上时,应用程序启动一个子例程,用于检查是否超过回收站(垃圾箱)的大小限制。但是,当我尝试获取垃圾箱中项目的信息时,出现的错误消息是:“Finder出错。找不到文件项目1。”我真的需要帮助:( 子程序如下所示: on check() tell application "Finder" set the total_size to 0

我是一个相当好的应用程序描述,并希望在此方面得到一些帮助。我正在制作一个类似于WindowsXP回收站的回收站应用程序。它当然是一滴。当我将项目放到应用程序上时,应用程序启动一个子例程,用于检查是否超过回收站(垃圾箱)的大小限制。但是,当我尝试获取垃圾箱中项目的信息时,出现的错误消息是:“Finder出错。找不到文件项目1。”我真的需要帮助:( 子程序如下所示:

on check() 
tell application "Finder"
    set the total_size to 0
    set the trash_items to get every item in trash
    if the trash_items is not {} then
        repeat with i from 1 to the count of items in trash
            set this_info to get info for item i of trash --ERROR ON THIS LINE
            set the total_size to the total_size + (size of this_info)
        end repeat
        try
            set the second_value to the free_space / (RBPFMS / 100)
            if the total_size is greater than the second_value then
                display alert "Size Limit Exceeded" message "The Recycle Bin cannot receive any more items because it can only use " & RBPFMS as string & " of your hard drive." buttons {"OK"} default button 1
                return false
            else
                return true
            end if
        on error
            set RBP to ((path to startup disk) as string) & "Recycle Bin Properties"
            display dialog "Error: You have modified the properties file for the Recycle Bin. Do not modify the properties file. It is there to store information that is used to determine the properties for the Recycle Bin." with title "Property File Modified" with icon 0 buttons {"OK"} default button 1
            set the name of RBP to "DELETE ME"
            error number -128
        end try
    end if
end tell
end check

该错误是由表达式
info for item i of trash
引起的。子表达式
item i of trash
返回一个(Finder)item对象。但是
info for
命令需要文件的别名或文件引用(请参阅)

有两种方法可以修复表达式。将项显式强制转换为别名,即:

repeat with i from 1 to the (count of items) in trash
  set this_info to get info for (item i of trash as alias)
  set the total_size to the total_size + (size of this_info)
end repeat
或者不使用
info for
命令,只需使用Finder项的
size
属性:

repeat with i from 1 to the (count of items) in trash
  set the total_size to the total_size + (size of item i)
end repeat
确保在
check
函数中将
RBPFMS
free_space
声明为全局变量:

on check()
    global RBPFMS
    global free_space
    ...
end
另一个错误:在
display alert
语句中,将
RBPFMS周围的括号作为string

display alert "Size Limit Exceeded" message "The Recycle Bin cannot receive any more items because it can only use " & (RBPFMS as string) & " of your hard drive." buttons {"OK"} default button 1

该错误是由表达式
info for item i of trash
引起的。子表达式
item i of trash
返回一个(Finder)item对象。但是
info for
命令需要文件的别名或文件引用(请参阅)

有两种方法可以修复表达式。将项显式强制转换为别名,即:

repeat with i from 1 to the (count of items) in trash
  set this_info to get info for (item i of trash as alias)
  set the total_size to the total_size + (size of this_info)
end repeat
或者不使用
info for
命令,只需使用Finder项的
size
属性:

repeat with i from 1 to the (count of items) in trash
  set the total_size to the total_size + (size of item i)
end repeat
确保在
check
函数中将
RBPFMS
free_space
声明为全局变量:

on check()
    global RBPFMS
    global free_space
    ...
end
另一个错误:在
display alert
语句中,将
RBPFMS周围的括号作为string

display alert "Size Limit Exceeded" message "The Recycle Bin cannot receive any more items because it can only use " & (RBPFMS as string) & " of your hard drive." buttons {"OK"} default button 1
当我尝试调用子例程时,它会出错“无法继续检查”

该调用需要在“check()”前面加一个“my”

告诉查找程序调用其“检查”子例程将不起作用。查找程序将告诉您它不知道如何“检查”。它将使用的词是“查找程序无法继续检查”。但您可以告诉查找程序调用本地定义的“检查”子例程。您只需在“检查”前面加上“我”的前缀即可当您调用子程序时。每次从tell块内部调用自己的子程序时,都需要这样做

当我尝试调用子例程时,它会出错“无法继续检查”

该调用需要在“check()”前面加一个“my”


告诉查找程序调用其“检查”子例程将不起作用。查找程序将告诉您它不知道如何“检查”。它将使用的词是“查找程序无法继续检查”。但您可以告诉查找程序调用本地定义的“检查”子例程。您只需在“检查”前面加上“我”的前缀即可调用子程序时。每次从tell块中调用自己的子程序时都需要执行此操作。

非常感谢!该问题现已解决。但是,当我尝试调用子程序时,它会出错“无法继续检查”。请检查子程序中的所有语句,好吗?那太好了。:)变量free_space和RBPFMS没有在check函数中定义。我知道。我把它们做成了全球性的变体,这样它们就可以在任何地方使用……再想想,我可能没有。我会查的。我查了一下,确保它们是全球性的,而且是全球性的。我不知道是什么导致了这个错误(非常感谢!这个问题现在已经解决了。但是,当我尝试调用子例程时,它会出错“无法继续检查”。请检查子例程中的所有语句,好吗?那太好了。:)变量free_space和RBPFMS没有在check函数中定义。我知道。我把它们做成了全球性的变体,这样它们就可以在任何地方使用……再想想,我可能没有。我会查的。我查了一下,确保它们是全球性的,而且是全球性的。我不知道是什么导致了这个错误(