Solved

I Need Help With MS-DOS

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
4 answers Last reply Best Answer
More about tomshardware
  1. First of all it's wrong forum. Secondly, why are you trying to make a game with this language? :O
  2. Best answer
    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
  3. 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
  4. Best answer selected by jacksonny.
Ask a new question

Read More

Games MS-DOS Video Games