applescript的dropitems列表无法正确显示

时间:2018-12-03 03:37:52

标签: applescript

我有以下代码:

var d = 0.123345678; 
var stringD = d.ToString(); 
int indexOfP = stringD.IndexOf("."); 
var result = stringD.Remove((indexOfP+1)+2);

我希望它允许我将文件拖放到applescript(保存为应用程序)上并显示类似于on open theDroppedItems set PosixList to {} repeat with a from 1 to length of theDroppedItems set theCurrentDroppedItem to item a of theDroppedItems set PosixPath to convertPathToPOSIXString(theCurrentDroppedItem) copy PosixPath to the end of the PosixList end repeat display dialog convertListToString(PosixList, space) end open on convertPathToPOSIXString(thePath) tell application "System Events" try set thePath to path of disk item (thePath as string) on error set thePath to path of thePath end try end tell return POSIX path of thePath end convertPathToPOSIXString on convertListToString(theList, theDelimiter) set AppleScript's text item delimiters to theDelimiter set theString to theList as string set AppleScript's text item delimiters to "" return theString end convertListToString 的列表,但是,它为我提供了2个对话框,其中1个指向第一个文件,然后是第二个以及第二个文件的路径。我想念什么?

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为此简化版本更符合您的需求?

on open theDroppedItems
    set posixList to {}
    repeat with a from 1 to length of theDroppedItems
        set theCurrentDroppedItem to item a of theDroppedItems
        set posixPath to POSIX path of theCurrentDroppedItem
        set end of posixList to (posixPath & linefeed & linefeed)
    end repeat
    display dialog posixList as string
end open
相关问题