@echo off
goto :food
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
:fruits
set i=0
for %%a in (apple banana grape lime) do (
set /A i+=1
set fruit[!i!]=%%a
)
set /a fruit=%random%%%4+1
set fruit=!fruit[%fruit%]!
exit /B
:food
for /l %%x in (1, 1, 5) do (
call :fruits
call :colorEcho 70 !fruit!
echo/
)
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
For some reason that I don't know, this code does not output correctly. It outputs just blank spaces because for some reason the "fruit" variable is never being filled. Can anyone explain this to me? I have another script which works fine using a similar structure but extracting these parts out of that script totally breaks it...any help is much appreciated!