You are not logged in.
I got a hand writing this code from someone on here awhile back which turned out to work just as i wanted, now a new problem has came to my attention this program will tell the user how many environment variables start with the letter they input, now what is i want them to be able to put in more then one letter separated by a space and it will tell them how many start with all, lets say 5 letters total?
SETLOCAL
SET /p "letter=Choose a letter "
if "%letter%" == "" (
echo Usage: Please enter a letter!
pause
exit /b 1
)
SET "letter=%letter:~0,1%"
FOR /f %%a IN ('2^>nul set %letter% ^|find /c "=" ' ) DO SET count=%%a
shift /1
ECHO %count% variables START "%letter%"
pause
Offline
I modified your code - test it to see how it goes.
@echo off
SETLOCAL
:begin
SET /p "letter=Choose a letter "
if "%letter%" == "" (
echo Usage: Please enter a letter!
pause
cls
goto :begin
)
for %%a in (%letter%) do call :routine %%a
pause
goto :eof
:routine
set letter2=%1
FOR /f %%a IN ('2^>nul set "%letter2:~0,1%" ^|find /c "=" ' ) do ECHO %%a variables START with "%letter2:~0,1%"
Offline
I modified your code - test it to see how it goes.
@echo off SETLOCAL :begin SET /p "letter=Choose a letter " if "%letter%" == "" ( echo Usage: Please enter a letter! pause cls goto :begin ) for %%a in (%letter%) do call :routine %%a pause goto :eof :routine set letter2=%1 FOR /f %%a IN ('2^>nul set "%letter2:~0,1%" ^|find /c "=" ' ) do ECHO %%a variables START with "%letter2:~0,1%"
Thanks, if you have the time would you be able to explain how your for loop that you added works?
Offline
Put an echo keyword before the call keyword and run it.
It should give you a clue as to how it works.
Offline