Sign in with
Sign up | Sign in
Your question
Solved

I Need Help With MS-DOS

Last response: in Video Games
Share
September 1, 2012 11:24:55 AM

I know this is probably really easy question
I am trying to make a game with MS-DOS.
I need to be able set the number of characters in a variable (PLAYERNAME) into a variable (PLAYERNAMELENGTH)

I try to use this code but it keeps on crashing :cry:  :

cls
set /p "PLAYERNAME=What is Your In-Game Name? (Must Be Under 10 Characters)?"
set #=%PLAYERNAME%
set PLAYERNAMELENGTH=0
:loop
if defined # (set #=%#:~1%&set /A PLAYERNAMELENGTH += 1& goto loop)
if %PLAYERNAMELENGTH% GTR 10 goto INVALIDPLAYERNAME
if %PLAYERNAMELENGTH% LEQ 0 goto INVALIDPLAYERNAME
goto CITYNAME

It says the syntax of the command is incorrect

Please, Help :D 

More about : dos

September 1, 2012 1:50:26 PM

First of all it's wrong forum. Secondly, why are you trying to make a game with this language? :o 
m
0
l

Best solution

September 1, 2012 2:10:49 PM

cls
set /p "PLAYERNAME=What is Your In-Game Name? (Must Be Under 10 Characters)?"
set #=%PLAYERNAME%
set PLAYERNAMELENGTH=0
:loop
if defined # (set #=%#:~1%&set /A PLAYERNAMELENGTH += 1& goto loop)
if %PLAYERNAMELENGTH% GTR 10 goto INVALIDPLAYERNAME
if %PLAYERNAMELENGTH% LEQ 0 goto INVALIDPLAYERNAME
goto CITYNAME
:INVALIDPLAYERNAME
Echo invalid player name
Pause
exit
:CITYNAME
Pause

Ammended it to this and ran in a batch file. Works fine on all different parts of the code. No errors with Vista 32
Share
Related resources
September 1, 2012 8:56:20 PM

tranzz said:
cls
set /p "PLAYERNAME=What is Your In-Game Name? (Must Be Under 10 Characters)?"
set #=%PLAYERNAME%
set PLAYERNAMELENGTH=0
:loop
if defined # (set #=%#:~1%&set /A PLAYERNAMELENGTH += 1& goto loop)
if %PLAYERNAMELENGTH% GTR 10 goto INVALIDPLAYERNAME
if %PLAYERNAMELENGTH% LEQ 0 goto INVALIDPLAYERNAME
goto CITYNAME
:INVALIDPLAYERNAME
Echo invalid player name
Pause
exit
:CITYNAME
Pause

Ammended it to this and ran in a batch file. Works fine on all different parts of the code. No errors with Vista 32


It must be a different part of the code.
I will have a look at the rest of the code.
Thanks for your help though tranzz :)  :D 
m
0
l
September 1, 2012 8:59:37 PM

Best answer selected by jacksonny.
m
0
l
!