我试图在我的主文件夹中写入文件(我使用的是Linux操作系统),而我正在将该文件写入临时文件,它正在工作。
put shell("echo $HOME") into last1上述获取主文件夹的代码,我将路径放置到变量last1中
put the text of field "bash1" into URL "file:last1/dic.sh" 这里,bash1是一个文本字段,它包含一些我想要写入主目录的shell脚本
下面的代码是有效的
put the text of field "bash1" into URL "file:/tmp/dic.sh"我如何重写我的代码
发布于 2015-05-15 15:19:10
由于您的last1变量包含在引号中,所以它被视为一个文字字符串,而不是一个变量。下列措施将起作用:
put field "bash1" into URL ("file:" & last1 & "/dic.sh")
注意,在从字段中放置文本时,不必显式地引用text属性--您可以这样做。此外,如果您在Linux上,可以使用~快捷方式引用用户的主目录:
put field "bash1" into URL "file:~/dic.sh"
发布于 2015-05-15 14:06:53
你必须“打开”文件,写你的东西,然后再“关闭”这个文件。
试着做些像
put last1 & "/dic.sh" into myFile
open file myFile for write
write the text of field "bash1" to file myFile
close file myFilehttps://stackoverflow.com/questions/30261325
复制相似问题