Batch Script Cant get If statements working -
my batch script working fine until tried add long if statements. im new , if check whats wrong. im trying pricing calculator based on rank are.
heres section of isn't working.
if "%drating%" < "1500" (set /a price=%price%+3) else if "%drating%" < "2000" (@set /a price=%price%+5) else if "%drating%" < "2500" (@set /a price=%price%+6) else if "%drating%" < "2700" (@set /a price=%price%+8) else if "%drating%" < "3000" (@set /a price=%price%+10) else if "%drating%" < "3300" (@set /a price=%price%+12) else if "%drating%" < "3500" (@set /a price=%price%+14) else if "%drating%" < "3800" (@set /a price=%price%+20) else if "%drating%" < "3900" (@set /a price=%price%+30) else if "%drating%" < "4000" (@set /a price=%price%+40) else if "%drating%" < "4100" (@set /a price=%price%+50) else ( echo there no available price %drating%. echo press key exit. set /p exitkey= )
heres did after magoo
if "%drating%" lss "1500" (set /a price=%price%+3 ) else (if "%drating%" lss "2000" (set /a price=%price%+5 ) else (if "%drating%" lss "2500" (set /a price=%price%+6 ) else (if "%drating%" lss "2700" (set /a price=%price%+8 ) else (if "%drating%" lss "3000" (set /a price=%price%+10 ) else (if "%drating%" lss "3300" (set /a price=%price%+12 ) else (if "%drating%" lss "3500" (set /a price=%price%+14 ) else (if "%drating%" lss "3800" (set /a price=%price%+20 ) else (if "%drating%" lss "3900" (set /a price=%price%+30 ) else (if "%drating%" lss "4000" (set /a price=%price%+40 ) else (if "%drating%" lss "4100" (set /a price=%price%+50 ) else (echo there no available price %drating%. echo press key exit. set /p exitkey= exit )
i simplify code , this.
@echo off set "price=10" set "drating=4099" if %drating% lss 1500 (set /a "price+=3" &goto skip) if %drating% lss 2000 (set /a "price+=5" &goto skip) if %drating% lss 2500 (set /a "price+=6" &goto skip) if %drating% lss 2700 (set /a "price+=8" &goto skip) if %drating% lss 3000 (set /a "price+=10" &goto skip) if %drating% lss 3300 (set /a "price+=12" &goto skip) if %drating% lss 3500 (set /a "price+=14" &goto skip) if %drating% lss 3800 (set /a "price+=20" &goto skip) if %drating% lss 3900 (set /a "price+=30" &goto skip) if %drating% lss 4000 (set /a "price+=40" &goto skip) if %drating% lss 4100 (set /a "price+=50" &goto skip) echo there no available price %drating%. pause goto :eof :skip echo drating=%drating% price=%price% pause
Comments
Post a Comment