China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-05 06:43
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about spaces in batch files, solved! View 870 Replies 2
Original Poster Posted 2007-07-01 14:57 ·  中国 山东 潍坊 联通
初级用户
Credits 23
Posts 10
Joined 2007-06-17 16:54
19-year member
UID 91614
Gender Male
Status Offline
When using IF in a BAT or CMD command to test keyboard input, if the input is a space, it gives an error!
For example:
:int
@ECHO off
set pass=0
set /P pass=请输入:
if %pass%==z goto end
goto INT

:end
pause
exit
If you enter a space when running it, it will say “goto was unexpected at this time”

[ Last edited by lzwqdbr on 2007-7-1 at 03:55 PM ]
Floor 2 Posted 2007-07-01 15:05 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
@ECHO off
:int
set pass=0
set /P pass=请输入:
if "%pass%"=="z" goto end
goto int

:end
pause
exit
Floor 3 Posted 2007-07-04 09:42 ·  中国 广东 东莞 电信
初级用户
★★
Credits 136
Posts 73
Joined 2007-04-02 05:47
19-year member
UID 83685
Gender Male
Status Offline
Learning from post #2!
Forum Jump: