Where the substring operation would return however many characters the user enters. If they enter "5", they'd get "12345".
Code: Select all
set String=1234567890 set /p x=Number of desired characters? echo %String:~0,%x%%
I've tried it using Delayed Expansion and that didn't seem to work either.
I can use a For token in the substring, and I've figured out a work-around for what I want to do, but it would be much simpler if there was a way to directly use a variable.
Is this possible?
After much experimentation, it seems that enabling delayed expansion and using !String:~0,%x%! works.