Multi-Line Comments in Batch File
The DOS/Windows batch language may not be as powerful as UNIX shell scripting language, but you can still get a lot of things done with it. The batch language only supports single line comments with the "rem" keywoard, which stands for remark. So to comment out the following example, you'd have to put the "rem" keywoard in front of every line:
rem if exist "%distroFile%" (
Well, that's a lot of work. As you can see in the example above, that's five line and a lot of typing. And you'd have to change the cursor position for every line. Don't you wish there is a C or Java-like multi-line comment (/* */) sequence?
Well, you can comment out multi-line statements by surrounding them with a goto and a label. The same example above would be changed to the following:
The goto statement will skip all of the statement below until it gets to the ":comment1" label. You'll just have to use a different label for each comment clause. Now, isn't that easier?
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
11 Users Online
Copyright © 1996 - 2017. All Rights Reserved.