Web Hosting, Design, & Coding forum

General discussion

Batch file help

by narumara / September 13, 2008 11:42 PM PDT

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 a reply
Discussion is locked
You are posting a reply to: Batch file help
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Batch file help
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Use quotes.
by Kees Bakker / September 13, 2008 11:55 PM PDT
In reply to: Batch file help

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

Works with me.

Kees

Collapse -
Nope...
by narumara / September 14, 2008 6:23 AM PDT
In reply to: Use quotes.

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

Collapse -
This was my test script.
by Kees Bakker / September 14, 2008 6:42 AM PDT
In reply to: Nope...

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

Collapse -
screenshot
by narumara / September 17, 2008 11:58 AM PDT

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.

Collapse -
If you look at the logic ...
by Kees Bakker / October 7, 2008 7:23 AM PDT
In reply to: screenshot

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

Kees

Collapse -
a different language
by zoredache / October 6, 2008 4:01 PM PDT
In reply to: Batch file help

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

Popular Forums
icon
Computer Help 49,613 discussions
icon
Computer Newbies 10,349 discussions
icon
Laptops 19,436 discussions
icon
Security 30,426 discussions
icon
TVs & Home Theaters 20,308 discussions
icon
Windows 10 360 discussions
icon
Phones 15,802 discussions
icon
Windows 7 7,351 discussions
icon
Networking & Wireless 14,641 discussions

Smartphone tip

Hoarding photos on your phone?

Those picture are hogging memory and could be slowing down your phone.