通过运行另一个 applescript 来更改一个 applescript 中的属性?
有谁知道如何通过运行另一个苹果脚本来更改一个苹果脚本中的属性? 我知道如何读取存储在单独脚本中的属性,但我不知道如何编辑它们。
例如。 文件 1 包含属性:(以“测试”形式保存到桌面)
property test : 1
文件 2 能够获取此属性的值
global test
set test to (load script (("/Users/knickman/Desktop/test.scpt") as POSIX file))
if test's test is 1 then
say "yes"
else
say "no"
end if
这有效。但是,如果我尝试从另一个脚本更改文件 1 中的值,方法如下:
global test
set test to (load script (("/Users/knickman/Desktop/test.scpt") as POSIX file))
set test's test to 1
这不起作用。我想做的事情可能吗?我试图用它作为一个简单的数据库。感谢您的帮助
Does anyone know how to change properties in one applescript by running another applescript?
I know how to read properties stored in a separate script but I can't figure out how to edit them.
For example.
File 1 contains the properties: (saved as "test" to the desktop)
property test : 1
File 2 is able to get the value of this property
global test
set test to (load script (("/Users/knickman/Desktop/test.scpt") as POSIX file))
if test's test is 1 then
say "yes"
else
say "no"
end if
This works. However, if I try to change the value in file 1 from another script with something along the lines of:
global test
set test to (load script (("/Users/knickman/Desktop/test.scpt") as POSIX file))
set test's test to 1
This doesn't work. Is what I am trying to do even possible? I am trying to use this to act as a simple database. Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
load script
加载脚本会创建存储在内存中 test.scpt 文件中的脚本对象的副本。修改加载脚本的属性只会更改内存中脚本对象的值,不会影响最初加载脚本的脚本文件。但是,您可以使用 存储脚本命令以使更改持久化:
Loading the script with
load script
creates a copy of the script object stored in the file test.scpt in memory.Modifying the loaded script's property will only change the value of the script object in memory, it does not have an effect on the script file that the script was originally loaded from. You can however use the store script command to make the changes persistent: