I Need Help With MS-DOS

jacksonny

Honorable
Sep 1, 2012
4
0
10,510
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
 
Solution
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

tranzz

Distinguished
Jun 13, 2008
92
0
18,660
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
 
Solution

jacksonny

Honorable
Sep 1, 2012
4
0
10,510


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