VOGONS

Common searches


First post, by kroltan

User metadata
Rank Newbie
Rank
Newbie

Okay, the problem with SET /P was answered by Qbix:

Qbix wrote:

SET /P is a NTVDM construct.
Not support in MS DOS 5.0
Use choice

And the actual problematic functionality was solved by aqrit:

aqrit wrote:
maybe use a .bat instead of .txt for config data then have each line in "LASTGAME.BAT" like […]
Show full quote

maybe use a .bat instead of .txt for config data
then have each line in "LASTGAME.BAT" like

SET line1=blah
SET line2=weee
SET line3=splat

And finally, the final .bat ended up like this:

@echo off
if "%1"=="" goto _load
goto play_%1
echo You don't have "%1" configured!
goto _end


:play_lemmings
cd lemmings
call cgalemmi.exe
goto _save
:play_quake
cd quake_sw
call quake.exe
goto _save
:play_warcraft
cd warcraft
call war.exe
goto _save
:_save
cd ..
echo call play %1 > LASTGAME.BAT
goto _end
:_load
call lastgame.bat
goto _end
:_end
cls

Thanks to all persons who helped me, and lastly, sorry for my bad english, it's my second language.

------------------------ORIGINAL POST-----------------------------
Not related to games, but actually a BAT file I'm creating to run games. ("Why not shortcuts?" Well that feels kind of out of place and boring to me)
The problem I'm having is when I try to load a text file that stores the last played game, DOSBox hangs and the console just spams:

SHELL:Redirect input from LASTGAME.TXT

And the DOS window crashes, forcing me to kill the process.
This is the file:

@echo off
IF "%1"=="" (
goto lastplayed
)
goto %1
echo You don't have "%1" configured!
goto end
:lemmings
echo Starting Lemmings!
cd lemmings
call cgalemmi.exe
goto save
:save
cd ..
echo %1 > LASTGAME.TXT
goto end
:lastplayed
set /P _lg=<LASTGAME.TXT
call play %_lg%
:end

The content is being saved fine, if I use "play lemmings", after the game exits the bat is saved with the content: lemmings
I tested it outside DOSBox and it loads the file correctly, so I guess it's a DOSBox problem. I tried the FOR technique, but it just hangs too without messages.
My computer's specs:
Motherboard: Pegatron IPM41-D3
Processor: Intel Pentium E5600 @3.2GHz (dual-core)[/code]

Last edited by kroltan on 2013-02-19, 16:01. Edited 1 time in total.

Reply 2 of 9, by kroltan

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

SET /P is a NTVDM construct.
Not support in MS DOS 5.0
Use choice

Okay, thanks! Will edit the post if it works.
EDIT: Could you provide an example? I don't understand how I would get the file contents out of CHOICE. Googled it and couldn't find a place that explained this. The most relevant things I found are these:
http://www.robvanderwoude.com/choice.php
http://ss64.com/nt/choice.html
In ss64.com, in the SET/P page, it does mention CHOICE as a alternative to read files, but doesn't explain how to use it.

Reply 3 of 9, by kroltan

User metadata
Rank Newbie
Rank
Newbie

Really sorry for this, but: Bump.
I searched everywhere I could and no site other than the two I mentioned in my earlier post talk about CHOICE to read files.
How would I use this command to read the file?

Reply 4 of 9, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

choice is used to make choices.
Most common set/p is used to make choices as well
They are not 100% identical or so.

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

Reply 9 of 9, by kroltan

User metadata
Rank Newbie
Rank
Newbie
aqrit wrote:
maybe use a .bat instead of .txt for config data […]
Show full quote

maybe use a .bat instead of .txt for config data

then have each line in "LASTGAME.BAT" like

SET line1=blah
SET line2=weee
SET line3=splat

YOU. ARE. A. GENIUS!
Since in my environment I am the only one who would modify the file, that would serve just well, because my main .bat would write valid batch to the lastgame.bat, I could simply call it! Kudos, Internets and whatever other reputation currency in existance for you!