If statement Dos Goto命令跳过

If statement Dos Goto命令跳过,if-statement,batch-file,goto,If Statement,Batch File,Goto,我写这个程序是为了把分数转换成百分比,但是我的goto命令被跳过了。它遍历程序并跳过if语句。代码如下: @echo off :menu Echo Fraction to Percent=1 Echo Percent to Fraction =2 set /p choice =Enter the number of your choice: if choice == 1 goto ftp if choice == 2 goto ptf if choice == 3 Exit :ptf pau

我写这个程序是为了把分数转换成百分比,但是我的goto命令被跳过了。它遍历程序并跳过if语句。代码如下:

@echo off

:menu
Echo Fraction to Percent=1
Echo Percent to Fraction =2
set /p choice =Enter the number of your choice:
if choice == 1 goto ftp
if choice == 2 goto ptf
if choice == 3 Exit

:ptf
pause

:ftp
set /p tn= Enter the top number:
set /p bn= Enter the Bottom number:
set /a mtn= %tn% * 100
set /a cf= %mtn% / %bn%
set /a cf2= %cf% * 10000
set /a mtn3= %tn% * 1000000
set /a cf3= %mtn3% / %bn%
set /a cf4= %cf3% - %cf2%
set /a cf5= %cf2% / 10000
echo %cf5%.%cf4%
goto continue


:continue
set /p con =Continue? (y/n):
if con ==y goto ftp 
if con ==n goto menu
问题 在这一行:
set/p choice=输入您选择的号码:

choice
是一个var,因此应该像so一样作为var引用
%choice%
而不是
choice
,所以如果我建议做…
如果“%choice%”==“1”转到ftp

提示
尝试添加如页面示例中所示的引号
如果“%choice%”==“1”转到关机

另请参见此处有关if语句的更多信息: