I will initially write something like this without namespacing:
main ();
function main () {
// This is the main function.
// From here I call other functions.
processDoc (app.ActiveDoc);
}
function processDoc (doc) {
// Call some other function from here.
processTables (doc);
}
function processTables (doc) {
// Do something here.
}
And I use a Python script to convert it to this:
// Make an object specific to this script.
var CP_ABC = CP_ABC || {};
// Add the functions to the object.
CP_ABC.main = function () {
// This is the CP_ABC.main function.
// From here I call other functions.
CP_ABC.processDoc (app.ActiveDoc);
};
CP_ABC.processDoc = function (doc) {
// Call some other function from here.
CP_ABC.processTables (doc);
};
CP_ABC.processTables = function (doc) {
// Do something here.
};
// Call the functions using the object "namespace".
CP_ABC.main ();
I got this idea out of this book:
https://www.amazon.com/JavaScript-Patterns-Better-Applications-Coding/dp/0596806752/ref=sr_1_3?ie=UTF8&qid=1528559325&sr…
Rick