Page 1 of 1

Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 15 Dec 2024 01:18
by nnnmmm

Code: Select all

@ECHO OFF
SET "KEYS=1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
SET /A CC=0
:DO-BEGIN
   SET /A CC=CC+1
   FOR /F "Tokens=%CC%" %%R IN ("%KEYS%") DO (
      SET "ANS=%%R"
   )
   IF %CC% GEQ 1 IF %CC% LEQ 9 SET DD= %CC%
   IF %CC% GTR 9 SET DD=%CC%

   ECHO %DD%. %ANS%.
   IF %CC%==40 GOTO :END
GOTO :DO-BEGIN
:END
PAUSE
Tokens do not pass after 31, is there some way that i can pass this limit?
i read the token 31 limit post in dostips, but it passed the limit of my understanding
this approach turned out to be useless at the moment, i have to use "input" command instead of "choice"

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 15 Dec 2024 09:22
by Aacini
You can use the method implemented at this reply.

For a description of the limitations of the FOR /F tokens command, see the reply before that. For a fully description of this matter, review the whole Using many "tokens=..." in FOR /F command in a simple way thread...

Antonio

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 15 Dec 2024 21:31
by nnnmmm
that was the post that i read and passed my limit. even if i understood, i would not be able to isolate the essential parts and insert them to my script to use. now i know where i stand, i can move on, i will just do it old unintelligent way
IF %CC%==1 SET ANS=1
IF %CC%==10 SET ANS=0
.
or
IF %CC% LEQ 31 (FOR /F "Tokens=%CC%" %%R IN ("%KEYS%") DO (SET "ANS=%%R"))
IF %CC%==32 SET ANS=V
IF %CC%==33 SET ANS=W
IF %CC%==34 SET ANS=X
IF %CC%==35 SET ANS=Y
IF %CC%==36 SET ANS=Z

thanks for the direction

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 16 Dec 2024 07:25
by T3RRY
You may get better help if you elaborate more on what form of data extraction you are trying to achieve.
Example data, inputs and outputs go a long way here.

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 16 Dec 2024 09:55
by Aacini
I am afraid I don't understand why you use precisely a FOR /F command that requires a tokens=40 switch. There are a lot of different ways to separate the elements of a list. For example, you can separate the elements in an array first, and then easily show the individual array elements. I am aware that you want not to use Delayed Expansion:

Code: Select all

@echo off
setlocal DISABLEDelayedExpansion

SET "KEYS=1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"

rem Separate individual keys in KEY array elements
set "n=0"
for %%a in (%keys%) do (
   set /A n+=1
   call set "KEY[%%n%%]=%%a"
)

rem Show they
SET /A CC=0
:DO-BEGIN
   SET /A CC=CC+1
   SET DD=%CC%
   IF %CC% LEQ 9 SET DD= %CC%

   CALL ECHO %DD%. %%KEY[%CC%]%%.
   IF %CC%==%n% GOTO :END
GOTO :DO-BEGIN
:END
Antonio

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 22 Jan 2025 22:03
by Izya Kurvitch
Maybe this will help...

Code: Select all

@echo off
setlocal enabledelayedexpansion
set "KEYS=1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for /f %%m in ('">$ cmd/v/c echo.!KEYS!& echo $"') do set /a char_count=%%~zm-2& del $
for /l %%a in (1,1,%char_count%) do (
set s=%%a&&call :pro
)
pause
:pro
set /a startchar=%s%-1
SET substring=!KEYS:~%startchar%,1!
echo %s%. %substring%.
exit /b

Re: Tokens do not pass after 31, is there some way that i can pass this limit?

Posted: 22 Jan 2025 23:11
by Izya Kurvitch
If you need spaces between chars, then:

Code: Select all

@echo off
setlocal enabledelayedexpansion
set "KEYS=1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
for /f %%m in ('">$ cmd/v/c echo.!KEYS!& echo $"') do set /a char_count=%%~zm-37& del $
for /l %%a in (1,1,%char_count%) do (
set s=%%a&&call :pro
)
pause
:pro
set /a startchar=-2+2*%s%
SET substring=!KEYS:~%startchar%,1!
echo %s%. %substring%.
exit /b