Windows batch label loop -
having hard time running batch file.
believe has if statements, doesn't fall through.
end "if unexpected @ time".
please grateful
:firstnumber set /p "firstnum = enter first number (other 22) " if "%firstnum%"=="22" ( goto :end ) else ( goto :secondnumber ) :secondnumber set /p "secondnum = enter second number (other 22 , 0) " if "%secondnum%"=="22" ( goto :end ) if "%secondnum%"=="0" ( goto :errornumber ) else ( goto :command ) :errornumber echo cannot divide 0 goto :secondnumber :command set /a quotient=%firstnum% / %secondnum% echo "%firstnum% divided %secondnum% = !quotient! :end
) if "%secondnum%"=="0" ( should be
) if "%secondnum%"=="0" ( the ) terminates previous if statement. cmd sees rest of line shouldn't follow )
(later - missing operand...)
batch sensitive spaces in set statement. set flag = n sets variable named "flagspace" value of "spacen"
hence, set /p "firstnum = ... sets variable called "firstnumspace" - , not same variable "firstnum"
since neither firstnum nor secondnum contain values, cmd sees
set /a quotient= /
lose spaces on both sides of = in set statements.
Comments
Post a Comment