Computing.Net > Forums > Disk Operating System > Batch files: blank lines, rem, ::

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch files: blank lines, rem, ::

Reply to Message Icon

Name: Renaissance Man
Date: May 17, 2002 at 05:23:07 Pacific
Comment:

I cant stand REM in batch files because it easier to type :: and it's a whole lot easier to read.

To skip a line (as between paragraphs or commands or sections) I remember reading somewhere long ago that the OS processes lines faster if you use :: or REM rather than just a totally blank line.

Is this true? If so, why?



Sponsored Link
Ads by Google

Response Number 1
Name: Miskva
Date: May 17, 2002 at 05:44:55 Pacific
Reply:

like you will see any difference .. maybe if you got 2000 rem statements in a single batchfile ...

I guess we are talinkg bout thousands of a second here


0

Response Number 2
Name: Secret_Doom
Date: May 17, 2002 at 10:41:45 Pacific
Reply:

I tested it, and it's true! I had never thought about it. This was the script I used to test it:

@echo off
if "%1"=="GoTo:" %1%2
echo.EXIT|%comspec%/k prompt $T$_|FIND ":"
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #2 %%?
echo.EXIT|%comspec%/k prompt $T$_|FIND ":"
goto eof
:#2
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #3 %3%%?
goto eof
:#3
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #4 %3%%?
goto eof
:#4
:eof

Put between ':#4' and ':eof' 10 blank lines, run the script, than change those blank lines for 10 lines with "::" and run it again. The second run will be faster! (the script outputs the runtime)

With 10 lines being tested, we actually have the prefix (:: or blank line) being read 10000 times in this script. These were the results, dividing the total runtime difference by the times the prefix was read:

[::] X [blank line] - 0.000031 s
[::] X [REM] - 0.000136 s

As you can see, not a big difference here, but the speed IS different:

speed: '::' > BLANK LINE > 'REM'

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 3
Name: Secret_Doom
Date: May 17, 2002 at 10:45:30 Pacific
Reply:

BTW, I've tested that under Windows 98 second edition, and my computer is:
PROCESSOR:PIII-700Mhz RAM:128MB

I have no idea why using "::" is faster than just a blank line.

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 4
Name: chip
Date: May 20, 2002 at 17:41:48 Pacific
Reply:

The reason why is that DOS still reads lines with REM in them, but :: is a "double label", which in DOS is invalid, and thus ignored.


0

Response Number 5
Name: Secret_Doom
Date: May 21, 2002 at 16:12:57 Pacific
Reply:

That what chip said seems to be true. Look these two lines:

REM comment > string
:: comment > string

The first line creates the zero-byte file named 'string', because of the ">" redirection. However, the second line doesn't do that.

But there's still something in my mind: the example is valid from inside a batch file and also at the command prompt. However, look the following example:

:: comment |

From the command prompt, such line returns "Bad sintax", but it doesn't from inside a batch file. Why?

Maybe DOS reads the double label and then ignore everything until the next line break or the next pipe.

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch files: blank lines, rem, ::

Batch file editing lines in sys.ini www.computing.net/answers/dos/batch-file-editing-lines-in-sysini/11887.html

Checking Exit Status of Batch File www.computing.net/answers/dos/checking-exit-status-of-batch-file-/11962.html

DOS BATCH FILE- PASSWORD www.computing.net/answers/dos/dos-batch-file-password/6402.html