2014-01-11 49 views
0
Set /P Input=[%CD%] 
For /F "tokens=1,2* delims=." %%A In ('Echo %Input%') do (
    Set "Root=%%A" 
    Set "Function=%%B" 
    Set "Execute=%%C" 
) 
If %Root%==File Goto File 
Goto Start 

REM These are the File.Commands 
:File 
If %Function%==Run Goto File_Run 
If %Function%==TestFor Goto File_TestFor 

在这个程序中,我有时会将变量“Function”留空,当我这样做时会关闭它,因为它将变量设置为“ECHO is off”,然后当我尝试比较它以防万一它不是空白但它是空白的,它关闭。我该如何解决?如何应对批量空白变量?

当我运行这个程序,“功能”是空的输出是: 后藤是意外的在这个时候。

然后关闭。

回答

1

尝试在IF -lines doubleqoutes避免语法错误:

If "%Function%"=="Run" Goto File_Run 

您可能需要添加一行:

If "%Function%"=="" Goto Empty_Function 
+0

三江源,我会尝试这一点,看看它是如何工作的。 – TheMountainFurnaceGabriel

+0

三江源,这确实解决问题。 – TheMountainFurnaceGabriel