number calculations in batch file

  • Thread starter Thread starter Dos group
  • Start date Start date
D

Dos group

I need to do a simple numbers calculation in a bacth file,
90-15. The first digit will always be constant but the second digit is a
variable, called %d1. So I need to calculate 90-%d1. Anyone have a tool to
script this and place the output into another variable, say %d2 ?
 
"Dos group" wrote in message
I need to do a simple numbers calculation in a bacth file,
90-15. The first digit will always be constant but the second digit is a
variable, called %d1. So I need to calculate 90-%d1. Anyone have a tool to
script this and place the output into another variable, say %d2 ?

You are unwise to name a variable %D1 since expansion will
be problematical unless you use !%D1! with Delayed Expansion
enabled.

As to simple calculation, see the SET /a command. For help
with this use /?
set /?

If you insist on using %D1 as your variable name, this screen
capture shows typical syntax

============Screen capture Windows 2000 simulated in Win95
C:\WORK>SET %D1=15

C:\WORK>SET /a RESULT=90-!%D1!
75
C:\WORK>ECHO Result is %RESULT%
Result is 75

C:\WORK>
============End screen capture
 
Dos said:
I need to do a simple numbers calculation in a bacth file,

61} How can one devise a command line calculator?
136348 Sep 25 13:47 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo
 
Timo, thanks for the link. I have used some of your stuff in the past. You
have some very nice scripts and wonderful documentation.
William, I was simply using very objective concepts in my email. I actually
used a much different naming convention in my scripts. Anyhow thanks for the
info as it did coincide with the suggestion Timo had as well.

Sincerely,
Rod Harrison
 
Back
Top