Thursday, February 17, 2011

Batch Calculator

Here is a small example of 'Set' command usage. The script below is a calculator, and as far as you can see we do almost nothing to calculate anything - just take the user's input data and send it to 'set' command that makes all calculations. Of course, this example is not a serious calculator, but it shows a very useful way to make some operations in batch scripts. You can easily include this code into batch files that you create with the help of our powerful batch files editor Dr.Batcher.
@ echo off
:begin
Cls
Title Calculator
Color 71
Echo Enter the expression:
Set /P exp=
Set /A result=%exp%
Echo Your expression: %exp%
Echo Result: %result%
Pause>nul
goto begin

No comments:

Post a Comment

Translate