How <cr> behaves in a variable?
Posted: 21 Aug 2019 06:09
Hi everyone!
My problem is that I have no idea how to check if a variable is equal with a <cr>(0x0d) charater.
So far what I got:
The var key comes from a read key method (with either the "replace /w" or "xcopy /w" method)
(this is the more efficient one)
Got the charater in the %CR% variable:
And now I'm trying to if it:
It gives me some output that i dont undertstand :/
The full test code:
Thanks in advance for helping
My problem is that I have no idea how to check if a variable is equal with a <cr>(0x0d) charater.
So far what I got:
The var key comes from a read key method (with either the "replace /w" or "xcopy /w" method)
Code: Select all
for /f skip^=1^ delims^=^ eol^= %%A in ('replace ? . /u /w') do set key=^%%A
Got the charater in the %CR% variable:
Code: Select all
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
Code: Select all
if %key%==%CR% Echo.
The full test code:
Code: Select all
setlocal enabledelayedexpansion
for /f "tokens=*" %%D in ("%cd%") do if %%~dD==%systemdrive% %systemdrive%
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
:beg
set/p "nnn=xcopy key:"<nul
set "keyx="
for /f "delims=" %%k in ('xcopy /w "%~f0" "%~f0" 2^>nul') do if not defined keyx set "keyx=%%k"
set "keyx=%keyx:~-1%"
echo %keyx%
echo The return for the %keyx%:
if %keyx% equ ^%CR% (echo Yes ) else echo nope
set/p "nnn=replace key:" <nul
for /f skip^=1^ delims^=^ eol^= %%A in ('replace ? . /u /w') do set keyr=^%%A
echo %keyr%
echo The return for the %keyr%:
if %keyr% equ ^%CR% (echo Yes ) else echo nope
goto beg