Version: 2008
  • On BNET: Is the Mac finally ready for the office?
Advanced Search
advertisement
advertisement
mySimon mySimon mySimon Outdoor Gear mySimon Swimwear mySimon Home and Garden

Forum display:

Coding & scripting: Batch file help

by narumara - 9/14/08 6:42 AM
advertisement
Click Here
Post 1 of 7

Batch file help

by narumara - 9/14/08 6:42 AM

Hey, i'm having some trouble with spaces in this script, can anyone help? Its a version of dungeonman me and my friend are working on, my problem is in the input: (if %input%== look tree goto grovetree) apparently it won't accept spaces as input, but i need it too for it to be effective, any suggestions?

@echo off
:opening
echo Weclome to thy dungeonman game of Asloria
echo.
pause
goto grove

:grove
cls
echo Thou art in yon mystical GROVE, thou hast one miserable headache, it must have some dungeonparty last night. Thou see around you yon TREE in yon middle of ye grove. Obvious exits are NORTH, SOUTH, EAST, and WEST.
set /p input=What doest thou deau?
if %input%== look tree goto grovetree

:grovetree
cls
echo Thou see yon TREE in thy middle of thy grove, it smells faintly of PARAPETS. CHARLIE is hanging from one of the branches, he is holding a SWORD, magestically posing with his hands at his hips.
echo.
set /p input=What doest thou deau?

Post 2 of 7

Use quotes.

by Kees Bakker Moderator - 9/14/08 6:55 AM In reply to: Batch file help by narumara

if "%input%"=="look tree" goto grovetree

Works with me.

Kees

Post 3 of 7

Nope...

by narumara - 9/14/08 1:23 PM In reply to: Use quotes. by Kees Bakker Moderator

well, i just tried that, but it didn't work, (if it changes anything, i have vista 64bit [but i doubt it does])

Post 4 of 7

This was my test script.

by Kees Bakker Moderator - 9/14/08 1:42 PM In reply to: Nope... by narumara

echo off
cls
set /p input="Input?"
if "%input%"=="with space" goto a
echo You did not enter 'with space'
goto end
:a
echo You entered 'with space'
:end

and it did what it should do if I executed it from the command prompt.

How does it work with you?

Kees

Post 5 of 7

screenshot

by narumara - 9/17/08 6:58 PM In reply to: This was my test script. by Kees Bakker Moderator

well i just copied ur script and saved it as .bat and ran it, it shows up as input? and then when i type in: with space it just shuts itself off.

Post 6 of 7

If you look at the logic ...

by Kees Bakker Moderator - 10/7/08 2:23 PM In reply to: screenshot by narumara

you'll see that it always should pass one of the echo-commands. So you should see something.

Kees

Post 7 of 7

a different language

by zoredache - 10/6/08 11:01 PM In reply to: Batch file help by narumara

With all due respect and all, but trying to write a full functioning game as a batch script is a horrible waste of time. Your end result will be a huge mess of spaghetti code.

Take some time, investigate python, basic, perl, vbscript or almost anything else then just shell script.

http://openbookproject.net/thinkCSpy/index.xhtml

Forum legend:
Locked Locked thread
Moderator Moderator
CNET staff CNET staff
Samsung staff Samsung staff
Norton Authorized Support team Norton Authorized Support team
AVG staff AVG staff
Windows Outreach team Windows Outreach team
Dell staff Dell staff
Intel staff Intel staff
Powered by Jive Software