Reputation: 159
Can't find the problem. Whenever I only input 1,an error occur. It says that ( unexpected at this time.But whenever I input other numbers as long as it has a 2 decimal places, it's okay.
@echo off
cls
setlocal EnableDelayedExpansion
echo|set /p= Input:
set /p input=
call :process
endlocal
goto :EOF
:process
if %input%==0 (
echo Input is 0
goto :EOF
)
if %input:~-3,1%==. (
if %input:~0,-3%==0 (
echo Less than 1
) else (
echo Greater than 1
)
) else (
echo Equal to 1
)
goto :EOF
Upvotes: 0
Views: 71
Reputation: 80213
if %input:~-3,1%==. (
means if [the string from the FOURTH character of input
for 1 character]==. (
When input is "1", [the string from the FOURTH character of input
for 1 character] is empty, so this is interpreted as
if ==. (
The if
statement expects if string1 operator string2 (dothis)
si it sees ==.
as string1 and can't work out what (
means as an operator - it is expecting one of a limited set; so it complains that (
was not expected.
Cure:
if "%input:~-3,1%"=="." (
Upvotes: 1