Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
nnnmmm
- Posts: 184
- Joined: 26 Aug 2017 06:11
#1
Post
by nnnmmm » 15 Dec 2024 01:18
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"
-
nnnmmm
- Posts: 184
- Joined: 26 Aug 2017 06:11
#3
Post
by nnnmmm » 15 Dec 2024 21:31
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
-
T3RRY
- Posts: 254
- Joined: 06 May 2020 10:14
#4
Post
by T3RRY » 16 Dec 2024 07:25
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.
-
Aacini
- Expert
- Posts: 1923
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#5
Post
by Aacini » 16 Dec 2024 09:55
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
-
Izya Kurvitch
- Posts: 21
- Joined: 15 Jul 2019 15:14
#6
Post
by Izya Kurvitch » 22 Jan 2025 22:03
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
-
Izya Kurvitch
- Posts: 21
- Joined: 15 Jul 2019 15:14
#7
Post
by Izya Kurvitch » 22 Jan 2025 23:11
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