Home > front end >  In Batch File - Testing if Value is Less than Zero
In Batch File - Testing if Value is Less than Zero

Time:10-26

I am running a mathmatical formula through a batch file for calculating volume displacement. I want to run an error check on the result to make sure the value is not negative. However, the value is always treated as positive when checked. I believe this is a result of batch's limited integers.

I used powershell to do the calculations. The result was put into %result% I tried to also use powershell to check if %result% was less than or equal to 0, and if it was it would GOTO Error. It only ever resulted in a crash.

Does anyone have any suggestions? Thank you!

@echo off
echo.
title RAM Displacement Calculator
:Start
cls

color E0

set /p Bore=Enter RAM Chassis Diameter (Bore): 
echo.
set /p Rod=Enter RAM Rod Diameter (Rod): 
echo.
set /p Extended=Enter Fully Extended Length: 
echo.
set /p Retracted=Enter Fully Retracted Length: 
echo.

color E9
echo | set /p status=Cal

for /f "delims=" %%a in ('powershell -Command %Extended%-%Retracted%') do set A=%%a
echo | set /p status=c
echo | set /p status=u
for /f "delims=" %%a in ('powershell -Command %Bore%*%Bore%') do set B=%%a
echo | set /p status=l
echo | set /p status=a
for /f "delims=" %%a in ('powershell -Command %Rod%*%Rod%') do set C=%%a
echo | set /p status=t
echo | set /p status=i
for /f "delims=" %%a in ('powershell -Command %B%-%C%') do set BC=%%a
echo | set /p status=n
for /f "delims=" %%a in ('powershell -Command %A%*           
  • Related