"Write" 在 Applescript 中向文本添加内容
"Write" in Applescript adds things to text
我对 applescript 比较陌生,如果这是一个愚蠢的问题,我深表歉意。当我 write (text & return) to file the randomFile starting at eof
它在开头添加 "listutxtplaceholderutxtº" 并在结尾添加 "utxt!utxt" ,这样当我 read
文件时这些东西就会显示出来。为什么要这样做?有解决方法吗?
感谢任何帮助!
当变量中的内容是 list
.
时会发生这种情况
确保它不是列表或将其作为列表处理 ()。
但是当 list
只有一项时你可以使用 as text
,像这样:
set myList to {"Hi"} -- this is a list with one item
write ((myList as text) & return) to file the randomFile starting at eof
来自 Apple Script Language Guide
:
List
A list defines an ordered collection of values, known as items,
of any class. As depicted in a script, a list consists of a series of
expressions contained within braces and separated by commas, such as
the following:
{1, 7, "Beethoven", 4.5}
A list can contain other lists. An empty list (containing no items) is
represented by a pair of empty braces: {}
.
AppleScript provides the list class
for working with lists.
我对 applescript 比较陌生,如果这是一个愚蠢的问题,我深表歉意。当我 write (text & return) to file the randomFile starting at eof
它在开头添加 "listutxtplaceholderutxtº" 并在结尾添加 "utxt!utxt" ,这样当我 read
文件时这些东西就会显示出来。为什么要这样做?有解决方法吗?
感谢任何帮助!
当变量中的内容是 list
.
确保它不是列表或将其作为列表处理 (
但是当 list
只有一项时你可以使用 as text
,像这样:
set myList to {"Hi"} -- this is a list with one item
write ((myList as text) & return) to file the randomFile starting at eof
来自 Apple Script Language Guide
:
List
A list defines an ordered collection of values, known as items, of any class. As depicted in a script, a list consists of a series of expressions contained within braces and separated by commas, such as the following:
{1, 7, "Beethoven", 4.5}
A list can contain other lists. An empty list (containing no items) is represented by a pair of empty braces:
{}
.AppleScript provides the
list class
for working with lists.