13

I have an App script project with several html files and 2 scripts(Code.gs, Utilities.gs). I want to be able to call functions from Utilities.gs in Code.gs but I dont know how to communicate between 2 scripts in one project. Is there a way to import/include scripts or something similar?

For example if I have a function called getInfo() in Utilities.gs I would like to call getInfo() in Code.gs. In java this would be Utilities.getInfo()

I dont see anything about this in the docs.

1 Answer 1

18

You don't need to do anything, every function in every script files in the same project are accessible from any script file... the separation in script files is only a comfortable way to store things the way you want. The project is the only "real" container.

Sign up to request clarification or add additional context in comments.

6 Comments

ahh, awesome. One more thing, is there a limit to the number of methods a single script file can have? I have been having this issue where if I add one more function(empty or not), crashes my script. If I then "make space" for the new methord by commenting out an existing method, the script runs fine. This is a Container bound script(Spreadsheet)
And moving methods from 1 script to another does not solve the issue specified above
I never experienced such issue although some of my scripts are pretty long... how many functions do you have and how long is your script ? are you sure the issue is related to script size ?
Exactly 50 methods with 1321 lines of code. If I add one more method this thing will crash. I dont want to think it's the number of methods but seems like it.
I'm not aware of a size limit...as I said, I've never had such issue. I'd suggest you expose your issue on the issue tracker to get Googlers attention. In the mean time please consider accepting this answer :-) .
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.