As you know, in Apps Script you can have libraries that can be accessed from other scripts. Apps Script automatically generates a namespace for that library (it calls it an identifier) which you prefix calls to functions to that library with.
Let's say you have a library called HandyLibrary, and you've included it as a resource, you can access functions in it like this
and variables in it like this
If you've implemented jsdoc in your library, you also get some limited autocomplete tips in the Apps Script editor when you save a version.
One useful benefit of namespaces is that you can limit the risk of global name collision (multiple scripts declaring the same global variable or function name for different things), since multiple namespaces can have the same locally named function - so
is not the same as
If you are developing a large project with multiple script files, and especially if you are copying code from existing projects, there's a chance that you'll waste a lot of time tracking down this kind of name collision problem. I recommend that you implement local namespaces in each of your script files to avoid this.
Here's how - Let's say you create a script file called Foo.
Create a name space - like this.
Add your variables and functions and functions that you would normally have declared globally inside your namespace
You can add pseudo classes inside that too
and the result
For more like this, see Google Apps Scripts snippets. Why not join our cummunity , follow the blog, twitter, G+ .
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >