你如何在applescript中包含一个? [英] How do you do an include in applescript?

查看:22
本文介绍了你如何在applescript中包含一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆代码想在几个不同的applescripts中使用,所以我想把它放到它自己的applescripts中,我可以从其他applescripts中引用.基本上我想做一个包含.这是如何在 Applescript 中完成的?

I have a bunch of code I want to to use in several different applescripts so I would like to put it into it's own applescript that I can reference from other applescripts. Basically I want to do an include. How is this done in applescript?

推荐答案

这是我找到的最佳方法.您可以像这样在另一个脚本上调用函数:

Here is the best way I have found to accomplish this. You can call a function on another script like so:

脚本 a.scpt

set myScript to load script "b.scpt"
set foo to myScript's theTest()

脚本 b.scpt

on theTest()
       return true
end theTest

如您所见,您可以通过调用函数名 myScript 的 theTest() 从 a.scpt 调用 b.scpt 中的函数.

As you can see you can call functions within b.scpt from a.scpt by calling the function name myScript's theTest().

这篇关于你如何在applescript中包含一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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