VOGONS


First post, by jparnell8839

User metadata
Rank Newbie
Rank
Newbie

OK, so I installed DOSbox for 1 simple reason: to play X-Com 😜 (months ago, mind you. I've installed a bunch of games now)

After a couple days of playing it, I realized what I had forgotten oh so long ago: X-Com is hard, painstaking, and frustrating. Thusly, I set out to download a DOS based saved game editor.

Now, it editing things, and testing them out, I got tired of:

cwxce\edit\xcomedit.exe
cd xcom
ufo.bat
cd ..
cwxce\edit\xcomedit.exe

etc, etc, etc...

So I wrote a batch file that is in my DOSbox startup directory called x.bat (yes, I'm lazy).

essentially, start the bat, runs the editor, upon close asks you if you would like to run X-Com. Yes, it runs X-com, No it returns to DOS. After it runs X-Com, it asks if you would like to run the editor. Yes, it loops, no, it returns to DOS.

Only problem is: as soon as I launch the batch file, it freezes up. Gotta CTRL + ALT + DELETE it and use the keyboard to kill the DOSbox process cuz the mouse renders non-responsive.

Here's my code:

@echo off

echo Hacking X-Com...
pause
cd cwxce\edit
xcomedit.exe
cls

:ask

SET /P ANSWER=Do you want to launch X-Com? (Y/N)?
if %ANSWER% == y goto :yes
if %ANSWER% == yes goto :yes
if %ANSWER% == Y goto :yes
if %ANSWER% == YES goto :yes
if %ANSWER% == Yes goto :yes
if %ANSWER% == n goto :no
if %ANSWER% == no goto :no
if %ANSWER% == N goto :no
if %ANSWER% == NO goto :no
if %ANSWER% == No goto :no
goto :ask

:yes
echo Launching X-Com...
pause
cd ..\..
cd xcom
ufo.bat
cls

:ask2

SET /P ANSWER2=Do you want to hack X-Com? (Y/N)?
if %ANSWER2% == y goto :yes
if %ANSWER2% == yes goto :yes
if %ANSWER2% == Y goto :yes
if %ANSWER2% == YES goto :yes
if %ANSWER2% == Yes goto :yes
if %ANSWER2% == n goto :no
if %ANSWER2% == no goto :no
if %ANSWER2% == N goto :no
if %ANSWER2% == NO goto :no
if %ANSWER2% == No goto :no
goto :ask2

:yes
echo Hacking X-Com...
pause
cd cwxce\edit
xcomedit.exe
cls
goto :end

:no
cls
goto :end

:no
cls
Show last 8 lines
goto :end

:end
echo Returning to DOS...
Pause
cd C:\DOS
cls

I thought maybe that the batch was taking up too much memory, however, it freezes up even in this simplest of batches:

@echo off


:ask

SET /P ANSWER2=Do you like DOS? (Y/N)?
if %ANSWER2% == y goto :yes
if %ANSWER2% == n goto :no

goto :ask

:yes
echo Fantastic!
pause
cls
goto :end

:no
echo Too bad...
pause
cls
goto :end

:end
cls
cd: ..\Windows

I've written numerous batch files to act as shortcuts to other things in DOSbox and they've never rendered it non-responsive. I have a strong feeling its the IF/THEN statement that's doing this.... is there a workaround I'm not aware of? I cant seem to find anything about it in either this forum or across the entire interwebs.

I've tested my batch file in the CMD prompt, replacing the executable (for the editor) and batch file (for launching X-Com) with simple "echo This is the editor" and "echo This is X-com". It all works in windows, just not in DOSbox 🙁

Any help you can give me would be greatly appreciated.

FYI:

OS: Win7 SP1 x64
DOSbox ver: 0.74

Need any other info, let me know...

Reply 2 of 10, by aqrit

User metadata
Rank Member
Rank
Member

SET /P is for windows command prompt only

you should use CHOICE instead (for DOS)

Reply 3 of 10, by SquallStrife

User metadata
Rank l33t
Rank
l33t
aqrit wrote:

SET /P is for windows command prompt only

you should use CHOICE instead (for DOS)

This.

Your first debugging step should have been to get rid of @ECHO OFF, to see which commands were failing.

VogonsDrivers.com | Link | News Thread

Reply 4 of 10, by jparnell8839

User metadata
Rank Newbie
Rank
Newbie
SquallStrife wrote:

This.

Your first debugging step should have been to get rid of @ECHO OFF, to see which commands were failing.

I did this (probably should have mentioned it, my bad on that) but it froze as soon as I run the batch.

aqrit wrote:

SET /P is for windows command prompt only

you should use CHOICE instead (for DOS)

Sounds reasonable. I'll have to look into the syntax of that command, DOS is a little before my time, I grew up with Win95 and up.

Thanks for the advice, both of you. I'll keep you posted on what happens.

Reply 5 of 10, by jparnell8839

User metadata
Rank Newbie
Rank
Newbie
collector wrote:

It is looping.

Care to elaborate? If this is the case, I dont see it. Not that I claim any kind of expertise, to be honest, I Googled this process (the Y/N input) out of boredom when I decided to write the batch file...

Reply 6 of 10, by collector

User metadata
Rank l33t
Rank
l33t

As stated by others, you should be using CHOICE. DOSBox is ignoring your menu and going straight to the "goto :ask", which loops back to "ask", over and over. When looking for batch file commands to use with DOSBox you need to use what is valid for DOS. Keep in mind that newer commands that have been added for modern Windows may not be recognized by DOS or DOSBox. Add DOS as a key word for your Google searches for batch file scripting.

The Sierra Help Pages -- New Sierra Game Installers -- Sierra Game Patches -- New Non-Sierra Game Installers

Reply 7 of 10, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

maybe I should add a E_Exit on set /p. As I've had a couple of emails this month on dosbox its broken batch support as well, which all turned out the user using set /p and not noticing that it failed.

Water flows down the stream
How to ask questions the smart way!

Reply 8 of 10, by jparnell8839

User metadata
Rank Newbie
Rank
Newbie

Well,the Choice command worked. Took me some tweaking and trial and error (such as having to use numerical input instead of Y/N), but it works. Here's the end script:

@echo off

echo Hacking X-Com...
pause
cd cwxce\edit
xcomedit.exe
cls

:BEGIN

CHOICE /C:12 /N Do you want to launch X-Com? (1=Y/2=N)?
if ERRORLEVEL ==2 goto no
if ERRORLEVEL ==1 goto yes

:yes
echo Launching X-Com...
pause
cd ..\..\XCom
xcom.bat
cls
goto end

:no
cls
goto end

:end
echo Returning to DOS...
Pause
cd C:\DOS
cls

the only thing I want to edit so that the 1=yes/2=no is on its own separate line. Any suggestions?

Reply 9 of 10, by aqrit

User metadata
Rank Member
Rank
Member

???
😒

@echo off

echo Your Message goes here
echo [Y/N]
CHOICE /n
if ERRORLEVEL == 2 goto no
if ERRORLEVEL == 1 goto yes

:yes
echo.
echo You selected YES!!!
goto end

:no
echo.
echo You selected NO...

:end
echo this is the end
Pause

Reply 10 of 10, by jparnell8839

User metadata
Rank Newbie
Rank
Newbie
aqrit wrote:
??? :disapproving: […]
Show full quote

???
😒

@echo off

echo Your Message goes here
echo [Y/N]
CHOICE /n
if ERRORLEVEL == 2 goto no
if ERRORLEVEL == 1 goto yes

:yes
echo.
echo You selected YES!!!
goto end

:no
echo.
echo You selected NO...

:end
echo this is the end
Pause

touche, my friend. I'm over thinking it