Is this possible

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Is this possible

#1 Post by explosivedolphin » 06 Sep 2016 13:44

I recently found a code for a number guessing game and I decided to edit the code a bit this is the original

Code: Select all

@echo off
color 0e
title Guessing Game by seJma
set /a guessnum=0
set /a answer=%RANDOM%
set variable1=surf33
echo -------------------------------------------------
echo Welcome to the Guessing Game!
echo.
echo Try and Guess my Number!
echo -------------------------------------------------
echo.
:top
echo.
set /p guess=
echo.
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!
if %guess%==%answer% GOTO EQUAL
set /a guessnum=%guessnum% +1
if %guess%==%variable1% ECHO Found the backdoor hey?, the answer is: %answer%
goto top
:equal
echo Congratulations, You guessed right!!!
echo.
echo It took you %guessnum% guesses.
echo.
pause


====================
here is what I changed
====================

Code: Select all

@echo off 
color 0e
echo Type your name to save your highscore.
set /p name=%name%
CLS
:start1
CLS
title Guessing Game Edited By AlternateAlt
set /a guessnum=0
set /a answer=%RANDOM%
set variable1=surf33
echo -------------------------------------------------
echo Welcome %name% to the Guessing Game!
echo -------------------------------------------------
echo Try and Guess my Number!
echo -------------------------------------------------
:top
set /p guess=
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!
if %guess%==%answer% set /a right=%right% +1 && goto hello11
set /a guessnum=%guessnum% +1
if %guess%==%variable1% ECHO Found the backdoor hey?, the answer is: %answer%
goto top
:hello11
echo Congratulations, You guessed right!!!
echo It took you %guessnum% guesses.
echo you guessed the number  right this many times %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>null
goto start1
:save
(echo ====================) >> highscore.txt
(echo Player=%name%) >> highscore.txt
(echo How Many Guessed Right=%right%) >> highscore.txt
(echo Number Of Guesses=%guessnum%) >> highscore.txt
(echo ====================) >> highscore.txt
goto start1
:wrong
echo Unknown Number Press Any Key Two Return
pause>null
goto  equal
:open
cd>null
notepad 'highscore'
CLS
goto hello11

====================
what I'm wondering is would it be possible to make it as you get closer to the number your guessing it changes colors and as you get farther away it changes color and also how would I make it save the date in the highscore text also any other improvements or changes would be appreciated.

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Is this possible

#2 Post by ShadowThief » 06 Sep 2016 19:00

Use the %date% variable to save the date. Also, I've changed null to nul, added colors, and cleaned up the grammar.

Code: Select all

@echo off
cls
color 0e
echo Type your name to save your highscore.
set /p "name= "
CLS

:start1
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a guessnum=0
set /a answer=%RANDOM%
set /a super_close_high=%answer%+10
set /a super_close_low=%answer%-10
set /a kinda_close_high=%answer%+100
set /a kinda_close_low=%answer%-100
set /a not_that_close_high=%answer%+1000
set /a not_that_close_low=%answer%-1000
set /a not_even_close_high=%answer%+10000
set /a not_even_close_low=%answer%-10000
set variable1=surf33
echo -------------------------------------------------
echo Welcome, %name%, to the Guessing Game!
echo -------------------------------------------------
echo Try and Guess my Number!
echo -------------------------------------------------

:top
set /p "guess="
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!

if %guess% lss %not_even_close_low% color 07
if %guess% gtr %not_even_close_high% color 07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% color 04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% color 04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% color 0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% color 0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% color 0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% color 0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% color 02

if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top

:hello11
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date: %date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#3 Post by explosivedolphin » 06 Sep 2016 19:09

thanks by the time you made those changes I had already made this but thank you I will integrate that into this

Code: Select all

@echo off 
color 0A
echo Type your name to save your highscore.
set /p name=%name%
CLS
goto start1
:start2
color 0F
echo ///LOADING///
echo ///LOADING///
echo ///LOADING///
CLS
:start1
color 0e
CLS
title Guessing Game Edited By AlternateAlt
set /a guessnum=0
set /a answer=%RANDOM%
if %Answer% gtr 100 goto start2
set variable1=surf33
echo -------------------------------------------------
echo Welcome %name% to the Guessing Game!
echo -------------------------------------------------
echo Try and Guess my Number!
echo -------------------------------------------------
set /a guesses=15
:top
echo you have %guesses% left
set /p guess=
if %guess% GTR %answer% goto Lower
if %guess% LSS %answer% goto Higher
if %guess%==%answer% set /a right=%right% +1 && goto hello11
set /a guessnum=%guessnum% +1
set /a guesses==%guesses% -1
if %guess%==%variable1% ECHO Found the backdoor hey?, the answer is: %answer%
goto top
:hello11
echo Congratulations, You guessed right!!!
echo It took you %guessnum% guesses.
echo you guessed the number  right this many times %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>null
goto start1
:save
(echo ====================) >> highscore.txt
(echo Player=%name%) >> highscore.txt
(echo How Many Guessed Right=%right%) >> highscore.txt
(echo Number Of Guesses=%guessnum%) >> highscore.txt
(echo ====================) >> highscore.txt
goto start1
:wrong
echo Unknown Number Press Any Key Two Return
pause>null
goto  equal
:open
cd>null
notepad 'highscore'
CLS
goto hello11
:Higher
color 0C
Echo ====================
color 0A
echo The Number Is Higher
color 0C
Echo ====================
color 0e
goto top
:Lower
color 0C
Echo ====================
color 0A
echo The Number Is Lower
color 0C
Echo ====================
color 0e
goto top

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#4 Post by explosivedolphin » 06 Sep 2016 19:23

Hay I Made a small change making it so the highest number is 100 but I have been trying to add a cap to how many times you can guess like 15 or something and it resets when you get it right how would I do that everything I've tried hasn't worked

Code: Select all

@echo off
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
goto start1
:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a guessnum=0
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
set /a super_close_high=%answer%+5
set /a super_close_low=%answer%-5
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
echo -------------------------------------------------
echo Welcome, %name%, to the Guessing Game!
echo -------------------------------------------------
echo Try and Guess my Number!
echo -------------------------------------------------

:top
set /p "guess="
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!

if %guess% lss %not_even_close_low% color 07
if %guess% gtr %not_even_close_high% color 07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% color 04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% color 04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% color 0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% color 0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% color 0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% color 0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% color 02
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top

:hello11
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date: %date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#5 Post by explosivedolphin » 06 Sep 2016 19:27

also if I could get it to say if its close or not like super close or kinda close if it would echo that but the two lines make me think I cant do that

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#6 Post by explosivedolphin » 06 Sep 2016 19:44

I put in :: what I wanted to add

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 0F
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+5
set /a super_close_low=%answer%-5
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
echo -------------------------------------------------
echo Welcome, %name%, to the Guessing Game!
echo -------------------------------------------------
echo Try and Guess my Number!
echo -------------------------------------------------

:top
set /p "guess="
if %guess% GTR %answer% ECHO Lower!
if %guess% LSS %answer% ECHO Higher!

if %guess% lss %not_even_close_low% color 07
if %guess% gtr %not_even_close_high% color 07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% color 04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% color 04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% color 0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% color 0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% color 0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% color 0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% color 02
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top

:hello11
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#7 Post by thefeduke » 07 Sep 2016 01:13

I added some presentation changes to what I believe was your latest afternoon post. Just added some color as you go, instead of changing the whole screen. It looks like this: Image I used Antonio's screen display utilities which can be found in topic "Advanced Batch features via auxiliary .exe programs" at http://www.dostips.com/forum/viewtopic.php?p=17101#p17101. I used show, colorshow and colorbox from the package. I did not examine you closeness logic or color choices. So here it is:

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+5
set /a super_close_low=%answer%-5
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo -------------"-----------------------------------
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from 1 to you guess." 13 10
echo "-----------------------------------------------"
colorbox /0f 0 0 48 4
:top
set /p "guess="

if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top

:hello11
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

John A.

Not sure about the picrure in preview, so the image url is http://imgur.com/a/EMLqs

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#8 Post by explosivedolphin » 07 Sep 2016 06:13

how do I use the advanced commands because those commands are not in cmd how would I make it work

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Is this possible

#9 Post by Squashman » 07 Sep 2016 06:19

explosivedolphin wrote:how do I use the advanced commands because those commands are not in cmd how would I make it work

Did you read the link John provided to you?

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#10 Post by explosivedolphin » 07 Sep 2016 06:21

Yes but couldn't make sense of it I'm so stupid.

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#11 Post by explosivedolphin » 07 Sep 2016 07:51

Hey I got it to work but the command colorbox didn't work and the colors don't change correctly some times and I still want to add the new colors in

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#12 Post by thefeduke » 07 Sep 2016 10:00

explosivedolphin wrote:Hey I got it to work but the command colorbox didn't work and the colors don't change correctly some times and I still want to add the new colors in
The most recent exact download instructions are in a very recent post in the same topic: http://www.dostips.com/forum/viewtopic.php?p=48090#p48090
Again, I left your color choices as-is.

John A.

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#13 Post by explosivedolphin » 07 Sep 2016 12:09

I figured out how to make it work but I would like to add the things in ::

Code: Select all

echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
set /p "guess="
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

also feel free to add anything else

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#14 Post by explosivedolphin » 07 Sep 2016 12:12

also is it possible to only allow the entrance of numbers from 1-100 when you a guess a number so you can only guess 1-100

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#15 Post by thefeduke » 07 Sep 2016 15:44

explosivedolphin wrote:also is it possible to only allow the entrance of numbers from 1-100 when you a guess a number so you can only guess 1-100
For that, I refer you to http://www.dostips.com/forum/viewtopic.php?p=44274#p44274 where Antonio wrote
Although ReadFormattedLine subroutine works perfectly, the code is somewhat large and complex and frequently the users are reluctant to use it when they have simpler requirements. The subroutine below is a much simpler version that just emulates the operation of SET /P command. This basic subroutine may be easily modified in order to fulfill any other requirement, like in this example that read only digits with a limited number of characters.

John A.

Post Reply