本文介绍了在几个* .gs文件中组织电子表格代码 - 甚至有可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在几个脚本文件中组织我的电子表格代码。在脚本编辑器中,我可以创建尽可能多的* .gs文件,但我无法弄清楚如何访问将在另一个脚本中定义的代码。
简单的例子,我想要达到的目的:
Code.gs:
function onEdit(){
myFunctionFromLibrary_gs();
}
Library.gs:
function myFunctionFromLibrary_gs(){
Browser.msgBox(hi there);
}
onEdit()显然是由Trigger调用的。
如果没有修改,会导致运行时错误,说明:
$ b
那么我该怎么做这个工作呢,还是目前不支持?
Thx提前为您提供帮助。
不知道 _gs
后缀对于Google来说意味着什么,但是如果没有它(参见下面的代码),代码就可以工作了。
file1.gs:
function onEdit(){
myFunctionFromLibrary();
file2.gs
function myFunctionFromLibrary(){
Browser.msgBox(hi there);
}
I am trying to organize my code for a Spreadsheet in several script files. Within the script editor I can create as many *.gs files as I want, but I can't figure out how to access code that would be defined in another script.
Simple Example of what I'd like do achieve:
Code.gs:
function onEdit(){
myFunctionFromLibrary_gs();
}
Library.gs:
function myFunctionFromLibrary_gs(){
Browser.msgBox("hi there");
}
The onEdit() is obviously called by a Trigger.Without modification this will result in a Runtime-Error, stating that
So how can I make this work, or is this currently not supported?
Thx in advance for your help.
解决方案
I don't know what the _gs
suffix means for Google, but without it (see code bellow), the code works.
file1.gs:
function onEdit(){
myFunctionFromLibrary();
}
file2.gs
function myFunctionFromLibrary(){
Browser.msgBox("hi there");
}
这篇关于在几个* .gs文件中组织电子表格代码 - 甚至有可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!