I am rather new to Google Scripts and JavaScript. I am writing a macro in Google Sheets and I am trying to skip down several lines of code. The code I am skipping is under development and putting in all those //
would be a pain and confusing later. This seems like a simple thing to do and have done it many times using Microsoft VBA. The only thing I can find in Google Scripts uses a label and a goto statement but that only seems to apply when the goto jumps to an earlier place in the macro.
I am just trying to jump down a couple of lines of code without using //
.
Any help will be Greatly appreciated.
Use a block comment to skip multiple lines permanently:
function myFunction() {
/*
Browser.msgBox('This is skipped.');
Browser.msgBox('This is skipped too.');
*/
Browser.msgBox('This runs.');
}
Alternatively use an If
statement and set a switch for debug mode. So you can switch your code execution from production mode into debug mode to run a different code.
var debugmode = true;
if (debugmode) {
Browser.msgBox('This runs only in debug mode.');
}