You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello All!
I couldn't find an old thread on ambn about this, so I started a new
one. ;)
The :splitStr subroutine:
* accepts the name of a variable and prints out every character in
the string stored in that variable on a line by itself
* can be safely CALLed with delayed expansion disabled or enabled
* handles all ASCII characters (except NUL) including CR and LF
* doesn't use a dog-slow goto loop
* sets errorLevel with the length of the string
- - - -
@echo off & setLocal enableExtensions disableDelayedExpansion
(call;) %= sets errorLevel to 0 =%
set "testStr=uncopyrightable"
call :splitStr testStr
if errorLevel 1 (
>&2 echo(string is %errorLevel% char(s^) in length
) else (
>&2 echo(empty string
goto die
) %= if =%
goto end
:splitStr string=
:: outputs string one character per line
setLocal disableDelayedExpansion
set "var=%1"
set "chrCount=0" & if defined var for /f "delims=" %%A in ('
cmd /v:on /q /c for /l %%I in (0 1 8190^) do ^
if "!%var%:~%%I,1!" neq "" (^
echo(:^!%var%:~%%I^,1^!^) else exit 0
') do (
set /a chrCount+=1
echo%%A
) %= for /f =%