[Batch] Incorrect Command Syntax!

Solved
Edgardu33 Posted messages 12 Registration date   Status Member Last intervention   -  
 Jesaispasquoimettre -
Bonjour,
Here is the translated text:

Hello,
So here I have a small problem with the batch code that I will provide below.
When I open it, it closes very quickly but I was able to distinguish this:
"The command syntax is incorrect" :/
Here is the code:

@echo off cls title Calcul COLOR 0c echo --------------- echo Test de Calcul By Edgardu33 echo --------------- echo. :debut set /a n1=%random%%%10 set /a n2=%random%%%10 :reessayer echo %n1% x %n2% ? set /p cho=> if %cho%==%n1% * %n2% (goto oui) else (goto non) :oui echo Bravo !!! echo. echo. goto debut :non echo Mauvaise reponse !!! echo. echo. goto reessayer 


Thank you in advance for your help.
Best regards, Edgardu33.

3 answers

LUDO
 
Hello,

it must be these lines:
if %cho%==%n1% * %n2% (goto oui)
else (goto non)

replace these lines with:
set /a resultat=%n1% * %n2%
if %resultat%==%cho% (
goto oui
) else (
goto non
)

That's it, see you later!
2
Edgardu33 Posted messages 12 Registration date   Status Member Last intervention   1
 
It's not working for me, I still have the same problem :/
Thanks for your help anyway :)
1
Jesaispasquoimettre
 
It is necessary to put a pause at the end.
0
LUDO
 
ok I tested it so here is the issue:
it's this line:
set /p cho=>

to be replaced by:
set /p cho=^>

indeed the sign ">" is a special character, to be indicated by the escape character "^" (Alt Gr + 8)

that's it see you later
1
Edgardu33 Posted messages 12 Registration date   Status Member Last intervention   1
 
Thank you very much!!!
0