Solved how to receive the input

October 16, 2013 at 01:59:31
Specs: DOS
@echo off
set /p input=please input a number:
set num1=%input%
set num2=123
if %num1% equ %num2% echo "="
if %num1% lss %num2% echo "<"
if %num1% gtr %num2% echo ">"
pause>nul

pure dos,not in the command(win),get error message on the line(set /p input=please input a number:),i got the reason why error(in the dos,command 'set' have no /p),but i have no idea to modify the code,nice guy can help me?

See More: how to receive the input

Report •

#1
October 16, 2013 at 06:43:39
✔ Best Answer
Yeah, you're learning the hard way that DOS is not CMD. As a courtesy to my nostalgia, I'll remove every line from your script that isn't valid MS-DOS 6.2.
@echo off
set num1=%input%
set num2=123
pause>nul

How To Ask Questions The Smart Way


Report •

#2
October 16, 2013 at 07:41:09
thanks for your answer,i mean is,under the dos environment,i wanna have a script
that receive the key which i input,then decide if the key is gtr 123 or not.
show "=" means equal,">" means greater and so on.the script i paste is ok in the CMD,
just what my purpose.

Report •

#3
October 16, 2013 at 09:07:04
The dos environment doesn't have if or set /p is what Razor2.3 is saying. The script you have will work in windows cmd because its available. You might be able to use qbasic or something like that,if it was still included with your environment.

::mike


Report •

Related Solutions

#4
October 16, 2013 at 09:29:19
@mikelinus

For sake of precision the DOS batch does not have if statement supporting maths operators as equ or lss just ==.


Report •

#5
October 16, 2013 at 09:43:09
Also, ERRORLEVEL. I think EXIST is also in DOS

How To Ask Questions The Smart Way


Report •

Ask Question