你如何正确地使用"写"在AppleScript的? [英] How do you properly use "write" in Applescript?
本文介绍了你如何正确地使用"写"在AppleScript的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法搞清楚如何在正确使用的AppleScript写。我现在有code是这样的:
I'm having trouble figuring out how to properly use "write" in applescript. I currently have code like this:
set randomArray to {"hello", "text", "file"}
set saveFile to (path to desktop as text) & "RandomFile.txt"
write randomArray to saveFile starting at eof as list
我知道,这是不对的,但我似乎无法找出正确的东西放在哪里了saveFile的那样。
I know that this is not right, but I can't seem to figure out what the correct thing to put where "saveFile" is would be.
任何帮助是AP preciated,感谢:)
Any help is appreciated, thanks :)
推荐答案
要写入一个文件一个很好的例子可以在code-片段中找到的(CTRL-点击进入一个脚本来看看它们) 的错误处理程序
,写入错误日志
。
A good example to write to a file can be found in the code-snippet (CTRL-Click into a script to see them) Error Handlers
, Write Error to Log
.
要保存的数组/列表您可以使用这样的:
To save an array/list you can use something like this:
set randomArray to {"hello", "text", "file"}
set fullText to ""
repeat with i from 1 to number of items in randomArray
set thisItem to item i of randomArray
set fullText to fullText & thisItem
if i is not number of items in randomArray then set fullText to fullText & return
end repeat
my scriptLog(fullText)
on scriptLog(thisText)
set the logFilePath to ((path to desktop) as text) & "Script Log.txt"
try
open for access file the logFilePath with write permission
write (thisText & return) to file the logFilePath starting at eof
close access file the logFilePath
on error
try
close access file the logFilePath
end try
end try
end scriptLog
这篇关于你如何正确地使用"写"在AppleScript的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文