Pergunta

I get the error "maximum recursion depth exceeded" after setting "setlocal enabledelaydexpansions" in my Batch script. I already read http://ss64.com/nt/setlocal.html but can't figure out how to workaround this problem. Here is the script causing this problem.

.

..

...

:MESSAGE
set /p "message=Message:"

setlocal enabledelayedexpansion

:ANALYSIS

if "%message%"=="%spam%" (
set /a counter=%counter% + 1
if !counter! GTR 2 (
goto :SPAM

) ELSE (
GOTO OK
)

) ELSE (
set counter=0
GOTO OK
)

:SPAM
echo.
echo stop spamming
echo.
GOTO MESSAGE

:OK
set "spam=%message%"

...

..

.

I tried setting "setlocal disabledelayedexpansion", "endlocal" after this script module but with no luck. Hopefully it's only little error I made.

EDIT:

Yes this seem to work, but I can't use exclamation marks now :( I set disabledelayedexpansion before entering %message% because of this.

I also saw now that this script makes more problems then I thought. Typing ^! brings up the value of the %message% variable defined later in in the script. Typing ^^! brings the next entry which changes %message%. Here are the values showing up:

REM Bad word filter with Format change for catching mutated vowels

chcp 1252>nul

SET before=%message%
SET message=%before:fuck=XXXXX%

SET before=%message%
SET message=%before:loser=XXXXX%

chcp 850>nul

^! gives me before:fuck

^^! gives me before:loser

Foi útil?

Solução

Each time you go into the :SPAM part, the :MESSAGE part is called via GOTO again.

Place the setlocal enabledelayedexpansionto the beginning of your batch

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top