Very basic guess the number program HELP!
Posted: 25 Feb 2012 11:57
I'm just starting to learn a few new languages and I was trying to make a batch program that chose a random number with %random% then told you higher or lower until you guessed correctly...
So far I have this:
@echo off
set Num=%random%
set /a Count=0
echo Try to guess the number!
:Top
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Lower
echo Too high try LOWER
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Higher
Too low try HIGHER
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Win
echo Well done you win!
echo The winning number was %Num%!
echo And it took you %count% tries!
Pause
It doesn't work

Help much appreciated!
So far I have this:
@echo off
set Num=%random%
set /a Count=0
echo Try to guess the number!
:Top
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Lower
echo Too high try LOWER
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Higher
Too low try HIGHER
set /a %count%+1
set /p udefine=
if %udefine% GTR %Num% GOTO Lower
if %udefine% LSS %Num% GOTO Highter
if %udefine%==%num% Goto Win
:Win
echo Well done you win!
echo The winning number was %Num%!
echo And it took you %count% tries!
Pause
It doesn't work


Help much appreciated!