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.
can dos batch files do math operations?
Name: David Date: December 28, 2000 at 09:24:12 Pacific
Name: ¤¤¥¤Ö Date: December 28, 2000 at 13:14:32 Pacific
Reply:
If the question is to win a bet on trivia, then I'd say yes. (There was a young man from Racine, who invented a screwing machine. Concave or convex, it would take either sex, but oh what a b---tard to clean!) In other words, it sure isn't easy. For example, one way to do so would be: to add two single digit number that are entered on the command line, if %1==1 goto 1x if %1==2 goto 2x if %1==3 goto 3x if %1==4 goto 4x if %1==5 goto 5x if %1==6 goto 6x if %1==7 goto 7x if %1==8 goto 8x if %1==9 goto 9x if %1==0 goto zerox goto end :1x if %2==1 goto say2 if %2==2 goto say3 if $2==3 goto say4 ----dot dot dot--- :say4 echo 4 goto done :say5 echo 5 goto done ---dot dot dot--- Using multiple batch files, and loops, this process could be made even easier. For example, you could write a small file that will increment (or decrement) an environment variable, like: if %myvar%==1 goto l2 if %myvar%--2 goto l3 ---dot dot dot--- :l2 set myvar=2 goto done ---etc.
0
Response Number 2
Name: Laurence Date: December 28, 2000 at 13:20:12 Pacific
Reply:
Absolutely! But, not as fast as a dedicated executable. I have on that adds, subtracts, multiplies and divides whole positive integers, but I used the "bang" principle so it is only practical for very small numbers. I plan on writing a much faster algorithm when I get time. http://home7.inet.tele.dk/batfiles/monthly/jun2000.htm
Also check out: http://home7.inet.tele.dk/batfiles/main/showcase.htm#savage
Name: bubbletrap Date: December 28, 2000 at 19:18:25 Pacific
Reply:
Here's a sample that I use to automatically run scandisk every tenth boot (by calling from autoexec.bat): @echo off call c:\batch\setcount.bat if not %count%==0 goto 1 set count=1 goto end :1 if not %count%==1 goto 2 set count=2 goto end :2 if not %count%==2 goto 3 set count=3 goto end :3 if not %count%==3 goto 4 set count=4 goto end :4 if not %count%==4 goto 5 set count=5 goto end :5 if not %count%==5 goto 6 set count=6 goto end :6 if not %count%==6 goto 7 set count=7 goto end :7 if not %count%==7 goto 8 set count=8 goto end :8 if not %count%==8 goto 9 set count=9 goto end :9 if not %count%==9 goto 0 scandisk set count=0 :end echo @set count=%count%>c:\batch\setcount.bat
Summary: Can a batch file count. I am in a DOS 6.22 class, and was given the assignment “Create a batch file that when invoked, makes a file that contains subdirectories and then counts them. This needs to b...
Summary: Does anybody know how I can open telnet session, insert the password, send commands to this session, and in one Dos batch file, or if someone has a better idea. ...