Computing.Net > Forums > Disk Operating System > Batch problem!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch problem!

Reply to Message Icon

Name: Dejan Jovanovic
Date: November 9, 2001 at 03:22:32 Pacific
Comment:

Can anybody explain why this doesn't work?
It's simple, just counts the lines in a file.
Stupid program just writes 0 in the loop and in the end the correct number.

set /a line=0
for /f %%i in (userstmp.txt) do (
set /a line += 1
echo %%i %line%
)
echo %line%

Thanks,
Dejan



Sponsored Link
Ads by Google

Response Number 1
Name: DoOMsdAY
Date: November 9, 2001 at 03:33:25 Pacific
Reply:

I'm guessing because all variables in Batch are strings (reason number 1) and Batch has absolutely no Math operations available to it (reason number 2). Unless you want some highly convoluted program to achieve that, I'd suggest just writing it in QuickBASIC or something similar.


0

Response Number 2
Name: astroraptor
Date: November 9, 2001 at 04:23:34 Pacific
Reply:

It's been done before though. In pure batch.

Try this site:
http://www.accesscomm.ca/users/gbraun/batch/


0

Response Number 3
Name: Laurence
Date: November 20, 2001 at 01:40:30 Pacific
Reply:

Batfiles: The DOS batch file programming handbook & tutorial


First,
Math operations _can_ be done in batch,
although it is exceedingly difficult
to understand.

Second,
That is a NT batch so the OP is in
the wrong place.



0

Response Number 4
Name: Marcus
Date: November 23, 2001 at 01:07:01 Pacific
Reply:

Hi!

Under NT, W2K or XP this Batchfile should work.
But your line
set /a line += 1
should go like this:
set /a line="line+1"

And please be aware, that it DOESNT work under a DOS System!
GREETS
Marcus


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


I need unformat.exe Odd commands? Any clue?



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 problem!

SOS! Need help with DOS Batch problem www.computing.net/answers/dos/sos-need-help-with-dos-batch-problem/7906.html

Help with DOS Class Batch Problem www.computing.net/answers/dos/help-with-dos-class-batch-problem/7885.html

IPconfig Batch Problems??? HELP????? www.computing.net/answers/dos/ipconfig-batch-problems-help/5684.html