如何在运行时使用applescript创建记录?


0

我想在运行时创建一个类型记录的变量,我发现这可以工作:

set bcd to run script ("{" & "abc" & ":" & "def" & "}")

但它没有:

error "The variable def is not defined." number -2753

我想在子程序中使用它,在哪里 abc def 将用变量代替。

如果你有一个键和一个值,如何在运行时在applescript中创建一个记录?

Answers:


1

尝试:

set def to "My Text"
set bcd to run script "{" & "abc:\"" & def & "\"}"

1

我最近做过类似的事情,这是我提出的最优雅的解决方案:

set scr to "on run argList
    return {|" & dictKey & "|: (item 1 of argList)}
    end run"

set newDict to (run script scr with parameters {dictVal})

希望它仍然有帮助!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.