I'm trying to take part of an input string (string: ~0.1%) and create a query using if-else-construct.
And it works correctly with (Input "1" as first character)
Code: Select all
@echo off
cls
setlocal enabledelayedexpansion
SET /p "string=Insert characters: "
ECHO Ouput part of string - first character= !string:~0,1!
if %string:~0,1% EQU 1 (
ECHO Output if first character = 1: Condition True
) else (
ECHO Output if not first character = 1: Condition False
)
I never reach "Condition True".
Code: Select all
@echo off
cls
setlocal enabledelayedexpansion
SET /p "string=Insert characters: "
SET /a counter=0
ECHO counter = %counter%
ECHO Ouput part of string - first character= !string:~0,1!
if %string:~%counter%,1% EQU 1 (
ECHO Output if first character = 1: Condition True
) else (
ECHO Output if not first character = 1: Condition False
)