I'm working on a program that's based on a device used in the early 20th century. While testing on parts of the program, a part of the code doesn't work like I thought it would. Here is some code that is similar to it:
@echo off
setlocal enabledelayedexpansion
cls
set /p ar=Type a number:
:loop
for /l %%a in (1,1,100) do (
set var1=%%a
if !var1! equ %ar%(
echo It worked
goto pause1
) else (
echo It didn't work
)
)
:pause1
pause
What I'm trying to do here is comparing the "%%a" variable with a variable set outside of the FOR command, but every time I tested the program, it would suddenly exit from the command prompt. I have tried changing the order of the commands, and changing the symbols, but the output is the same. I've checked many references and I haven't found any that tackles this certain scenario. Can you tell me what I'm doing wrong here and what to do to fix it? Thank you.
Aucun commentaire:
Enregistrer un commentaire