Rem comment batch files


















Although you can use rem without a comment to add vertical spacing to a batch file, you can also use blank lines. Blank lines are ignored when a batch program is processed. To include an explanatory comment before the prompt command in a config. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Is this page helpful? Please rate your experience Yes No. Any additional feedback? The below lines are multiple line comments.

Now that you are familiar with the syntax, let us try it in practice. We will write a small program to test the comments. As I said above the first line is the comment and the next line prints Hello, World!!!. The problem with the comments is that though they are ignored by the interpreter, still echoed back to command prompt. When we run the program, we get the output as follows. Hello, World!!! So, we will try placing the echo off on the first line of program and revise the program.

See the output below. Output Hello, World!!! Press any key to continue. There are some situations where you need to keep echo command in on state. During such cases, the comments are also echoed back on the screen. So, we will try to solve it by revising the program. This program gives the output same as the program version 3, But illustrates a different type of comments. You may also include these type of comments in your batch file if feel bored with REM command.

REM command must be followed by a space or tab character. You may include any symbol in the comments without any restriction. Otherwise, it is ignored. You can also place a comments in a batch file by starting the comment line with two colons [::] as shown below.

This is the basic syntax for multiple line comments. Every line may be replaced with comments. Hence we allow multiline comments without having to use REM command before each line. Try it out yourself!

If you have a remark using the double-colon :: style inside of a FOR loop it can lead to problems, while REM never will. Your email address will not be published. Skip to content Well, we have already started with the basics and already wrote our first program in the previous discussions. Hope you followed them. If not, go back and read them before you proceed into the operators in batch files. Just like all other scripting languages, batch files also support a very large variety of operators classified into different groups.

REM [Comment]. REM [ Comment ].



0コメント

  • 1000 / 1000