Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REM in multi-line commands

115 views
Skip to first unread message

Tom Del Rosso

unread,
Jan 10, 2012, 8:40:35 PM1/10/12
to

I just read in technet that REM statements are invalid inside multi-line
commands, but I use them all the time. Is that a NT1-4 thing?


--

Reply in group, but if emailing add one more
zero, and remove the last word.


foxidrive

unread,
Jan 10, 2012, 10:57:37 PM1/10/12
to
On 11/01/2012 12:40, Tom Del Rosso wrote:
> I just read in technet that REM statements are invalid inside multi-line
> commands, but I use them all the time. Is that a NT1-4 thing?
>
>

If you use this it skips the second echo

@echo off
echo abc&rem skip this&echo def&^
echo xyz
pause


but this works ok (XP SP3)


@echo off
echo abc&^
rem skip this&^
echo def
pause





--
Regards,
Mic

Todd Vargo

unread,
Jan 10, 2012, 11:56:07 PM1/10/12
to
On 1/10/2012 8:40 PM, Tom Del Rosso wrote:
> I just read in technet that REM statements are invalid inside multi-line
> commands, but I use them all the time. Is that a NT1-4 thing?

While it may work, it is a good idea to avoid REM and/or labels in
multi-line statements to minimize unexplained errors.

In XP, it seems that once a multi-line REM error occurs, the batch will
continue to have unexplained errors, even after the error is corrected,
until the cmd session is closed and a new session opened. Ted Davis
refered to this anomaly of unexplained errors as XP's behavior randomizer.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Frank P. Westlake

unread,
Jan 11, 2012, 9:58:21 AM1/11/12
to
On 2012-01-10 17:40, Tom Del Rosso wrote:
>Is that a NT1-4 thing?

It began there then they made some repairs, but apparently it is not
completely usable. If I remember correctly, in NT4 this

(REM comment
command
)

became this when the line was loaded

(REM comment & command)

so that the result was unbalanced parentheses.

Frank

I'm_HERE

unread,
Jan 11, 2012, 12:47:23 PM1/11/12
to

Frank P. Westlake

unread,
Jan 11, 2012, 1:13:47 PM1/11/12
to
On 2012-01-11 09:47, I'm_HERE wrote:
> http://stackoverflow.com/questions/8526946/commenting-multiple-lines-in-dos-batch-file/8533464#8533464

I don't think I have access to submit messages to that group so I'll
comment here.

Probably the most versatile method is to make use of MS's original
concept of an environment variable, which is simply pasting in text.
This fails with delayed expansion (!var!) variables so the original type
(%var%) must be used.

Set "debug1=ECHO >NUL: "
Set "debug2="

%debug1% SomeStatement
%debug2% SomeOtherStatement

The 'debug1' line is printed to NUL: and the 'debug2' line is unaffected
because 'debug2' is undefined. I used two debug variables just to
demonstrate that lines can be selectively disabled from the top of the
script.

Frank
0 new messages