将列表转换为applescript数组 [英] Turn list into applescript array

查看:234
本文介绍了将列表转换为applescript数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个applescript函数,可以处理数组的每个项目.我正在寻找一种将以下列表拖放到我的applescript文件中的方法:

I have an applescript function which processes each item of an array. I'm looking for a way to drop a list like the following into my applescript file:

arrayitem1
arrayitem2
arrayitem3

并使用applescript自动将其格式化为正确的applescript数组语法,因此我得出以下结论:

and to use applescript to automatically format it into the proper applescript array syntax so I end up with this:

set array1 to {"arrayitem1", "arrayitem2", "arrayitem3"}

您可以想象,对于更长的数组,手动添加所有逗号和引号会很麻烦.

As you can imagine, for longer arrays it would be a hassle to manually add all the commas and quotations.

谢谢!

推荐答案

set stringofitems to "
item1
item2
item3
"

set text item delimiters to "
"

set listofitems to text items of stringofitems

repeat with theitem in listofitems

    # stuff to do with each item

end repeat

这篇关于将列表转换为applescript数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆