Reputation: 7627
I have a quite long gnuplot script. For debugging purposes, I would like to be able to block comment parts of this script or use a "goto" statement. Is this possible?
I know I can use an if
statement:
if (1 == 2) {
commented-out-code
} else {
non-commented-out code
}
Is this the only solution?
Upvotes: 9
Views: 19425
Reputation: 10238
Gnuplot doesn't support block comments (as of version 5). But since Gnuplot interprets your script, the solution you gave does the job. But instead of using an expression to be falsified (evaluated to 0
), use a maximally obvious notation (for safety add a comment for its purpose). Spare the else
block as it's noting but complicating things.
Look on the following example, to see that it's not as easy as one might think.
if (0) { # commented-out block
This block is completely ignored by Gnuplot.
Well, obviously not completely...
# }{
...because Gnuplot is not just looking for the closing curly brace ;-)
}
Upvotes: 6
Reputation: 6707
Another solution to the one proposed by @choroba is to separate the parts of the script into different files, then manage a "master" file that calls the ones you haven't commented:
# master script
load "part1.plt"
#load "part2.plt"
load "part3.plt"
Upvotes: 5
Reputation: 242123
Comments in gnuplot start with a #
. If you want to comment a whole block, your text editor should be able to do that (e.g. M-; in Emacs with the block selected).
Upvotes: 8