1

我正在尝试解析从 Applescript 中的文件读取的一组行。

这就是我的代码的样子:

my status_dialog(indexData)
set AppleScript's text item delimiters to return
set indexFreq to (text items 1 thru 1 of indexData)

indexData 包含一组行。行分隔符不起作用。indexFreq 再次返回整组行而不是第一行。

我是这里的新手,在线资源对我没有帮助。

非常感谢!普拉迪普

4

1 回答 1

1

您的代码应该按预期工作。问题可能在于这return不是这组特定行的正确字符。换行符可以是回车、换行或两者兼有,具体取决于创建文件的程序或系统。

您可以尝试使用不同的字符而不是return

tell me to set the text item delimiters to (ASCII character 10) --// LF
tell me to set the text item delimiters to (ASCII character 13) --// CR

此外,为确保您的其余代码设置正确,请进行简单测试:

set test_string to "thisQisQaQtest"
set the text item delimiters to "Q"
return text items of test_string

这应该产生以下内容(在您的 AppleScript 控制台中):

{ “这是一个测试” }

于 2009-04-27T21:47:22.000 回答