0

I am looking into an issue regarding a command I've recently run into an issue with.

The command I'm referring to is the following...

set %num%=%string:~%num%,1%

[Goal]:My goal with this command is to take a string, skip "num" digits, take that single digit in the string, and then be labeled the variable "num."

[Question]:What is the issue with my syntax/What should I do know?

Below is the full program, unnecessary assets removed. [The call command early on calls a short function which counts the characters and returns a number.]

@echo off
set /p string=
call :strlen result string
set /a num=0
:re2
::============================Problem Command
set %num%=%string:~%num%,1%
set /a temp=%num%
set temp2=%num%
:re3
if %%%temp%%%==%%%temp2%%% goto win
if %temp%==0 goto re4
set /a temp=%temp%-1
goto re3
:re4
set /a num=%num%+1
goto re2
:win
::...
  • Read https://ss64.com/nt/set.html and https://ss64.com/nt/syntax-substring.html – JosefZ Mar 01 '18 at 10:29
  • @JosefZ If you would like to put your links as a solution, I can mark this question solved and have your links as a front-runner. – Fierce Thunder Mar 01 '18 at 10:37
  • 2
    Hmm… Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow. Similarly, link-only answers are considered poor-quality ones. Please [edit] the question if you get stuck on a specific problem and need more help… – JosefZ Mar 01 '18 at 11:04
  • 1
    Try `set %num%=!string:~%num%,1!` (with `setlocal enableDelayedExpansion`) or `call set %num%=%%string:~%num%,1%%`. Further details at [this answer](https://stackoverflow.com/a/10167990/778560) (even if the topic is different)... – Aacini Mar 01 '18 at 14:52
  • @Aacini I actually started using your second suggestion from the source the previous and first commentor suggested – Fierce Thunder Mar 03 '18 at 07:03

0 Answers0