Posts: 285
Threads: 70
Joined: Feb 2005
Many of the younger in the forum may never have come across the ancient BATCH.COM DOS program for creating a simple menu using a .BAT file. Being a .BAT fill it consumes very little RAM so should run ANY DOS program. Below is an example of a Games menu I am constructing using the brilliant DOSBOX available from
http://dosbox.sourceforge.net which I am using to run a number of old DOS programs and games that I thought I would never get to run again on a modern PC with Win. XP etc.
You can pick up the BATCH program from
http://sionet.mysite.wanadoo-members.co.uk/PCA.zip along with the nice PCA filemanager that displays ALL files irrespective of how your Windows File settings are cunstomised. Gordon
Code:
REM Batmenu (c) G.Sweet Ver 2
ECHO OFF
:START
CD \
CLS
ECHO .
ECHO MENU OF DOS GAMES.
ECHO .
ECHO Make sure the Caps Lock is OFF then press :-
ECHO .
ECHO a = Asteroid b = Blast c+ = Casino.
ECHO .
ECHO d = Abort to DOS
BATCH/B
BATCH/A ?
ECHO .
REM Errorlevel must be greater than last option for re-START
IF ERRORLEVEL 122 GOTO END
IF ERRORLEVEL 99 GOTO c
IF ERRORLEVEL 98 GOTO b
IF ERRORLEVEL 97 GOTO a
REM Errorlevel to trap keys less than 97 = a
IF ERRORLEVEL 32 GOTO START
:a
CD \486GAMES\ASTEROID
ASTEROID
GOTO START
:b
CD \486GAMES\BLASTER
BLAST
GOTO START
:c
CD \486GAMES\CASINO
CASINO
GOTO START
:END
CLS
ECHO ON
Posts: 1,774
Threads: 62
Joined: Aug 2003
He he he... That reminds me of how proud I was when I learned how to make a batch from scratch.
Man, I made this
humungous menu thing for my first QB games... It was just ridiculous. :lol:
Posts: 243
Threads: 12
Joined: Aug 2001
But why mess with that? Just write a QBasic program
Assumes you are already in 486GAMES, i.e. your original BAT is
Code:
@echo off
cd \486GAMES
qbasic /run Menu
Code:
CLS
LOCATE 5, 30: PRINT "MENU OF DOS GAMES"
LOCATE 8, 35: PRINT "a = Asteroid"
LOCATE , 35: PRINT "b = Blast"
LOCATE , 35: PRINT "c = Casino"
LOCATE , 35: PRINT "d = Abort to DOS"
PRINT
LOCATE , 32, 1: PRINT "Choice: ";
DO
DO: k$ = INKEY$: LOOP WHILE k$ = "": PRINT k$: PRINT : PRINT
SELECT CASE UCASE$(k$)
CASE "A": Shellx "Asteroid"
CASE "B": Shellx "Blast"
CASE "C": Shellx "Casino"
CASE "D": CLS : SYSTEM
CASE ELSE: PRINT "No such choice": CALL Refresh
END SELECT
LOOP
SUB Refresh
PRINT "Press spacebar to refresh"
DO: k$ = INKEY$: LOOP WHILE k$ <> " "
RUN
END SUB
SUB Shellx (Game$)
'shell Game$
PRINT "Started " + Game$
CALL Refresh
END SUB
Posts: 1,439
Threads: 15
Joined: Apr 2003
... because other people can run your .bat files without loading Qbasic. Of course, you could compile to an EXE with QB, but really, a .bat is better in that it's editable by the end-user - that could be a downside, though, depending on how you look at it.
Posts: 285
Threads: 70
Joined: Feb 2005
The reason why I would use a BAT file instead of ANY program as a menu, is sometimes Games/Programs fail to run because of lack of RAM taken up by the menu. Please try out you idea on various DOS programs or games yourself.
This is why a QB menu I produced many moons ago also runs from a BAT file, by altering the BAT file to run the program. I copied the idea from a DOS menu program called Menumaster. Anyone is welcome to my menu if they buzz men. Unfortunately for some reason my dear old DOS menu now fails to work properly under the excellent DOSBOX, because it will not allow the DOS menu to alter the BAT menu from which it runs.
Gordon
Posts: 780
Threads: 49
Joined: Dec 2001
I used to use a little com i wrote in DEBUG called getkey.com. It was basically a copy of the famous getkey program...but it was minute, and it returned the errorlevel.
I once wrote a game in batch...I'll look for it.
Posts: 1,774
Threads: 62
Joined: Aug 2003
Quote:I once wrote a game in batch...I'll look for it.
I started one, but then I discovered DirectQB and all was lost. :lol:
Posts: 285
Threads: 70
Joined: Feb 2005
I have discovered there appears to be a limit to the number of options this BATCH.COM technique can cope of around 25. But you can use CALL MENU2 as an option to divert to another menu.
I had a look around my collection of ancient DOS progs. to see if I had a GETKEY without success of course. But I did find a couple more BAT menu programs, I have now put up in below. Just run thenm under DOS to see their details.
http://sionet.mysite.wanadoo-members.co.uk/PCA.zip
Gordon
Posts: 243
Threads: 12
Joined: Aug 2001
Hi, DrV
Quote:because other people can run your .bat files without loading Qbasic
I assume you mean that people who do not have QBasic.EXE on their machine can run. That is no benefit if, instead, they must load ask.com or whatever software you are using to query the user. In either case they have to modify their system. As a QBasic lover, I would recommend they load QBasic.
Hi, GordonSweet,
Quote:The reason why I would use a BAT file instead of ANY program as a menu, is sometimes Games/Programs fail to run because of lack of RAM taken up by the menu. Please try out you idea on various DOS programs or games yourself.
Good point. Now, if that is the only reason you are avoiding a QBasic program to do this, try the one below. It works with no memory usage by the menu during game play.
Mac
Code:
' This program must be in your Games directory
' It must be named Menu.BAS
' There must also be Menu.BAT as follows:
' @echo off
' qbasic /run Menu
' if exist MenuGo.bat MenuGo.bat
CONST Xfer = "MenuGo.bat"
ON ERROR GOTO Ignore: KILL Xfer: ON ERROR GOTO 0
CLS
LOCATE 5, 30: PRINT "MENU OF DOS GAMES"
LOCATE 8, 35: PRINT "a = Asteroid"
LOCATE , 35: PRINT "b = Blast"
LOCATE , 35: PRINT "c = Casino"
LOCATE , 35: PRINT "d = Abort to DOS"
PRINT
LOCATE , 32, 1: PRINT "Choice: ";
DO
DO: k$ = INKEY$: LOOP WHILE k$ = "": PRINT k$: PRINT : PRINT
SELECT CASE UCASE$(k$)
CASE "A": PGM$ = "Asteroid"
CASE "B": PGM$ = "Blast"
CASE "C": PGM$ = "Casino"
CASE "D": CLS : SYSTEM
CASE ELSE:
PRINT "No such option. Press spacebar to acknowledge"
DO: k$ = INKEY$: LOOP WHILE k$ <> " "
END SELECT
LOOP WHILE PGM$ = ""
OPEN Xfer FOR OUTPUT AS #1
PRINT #1, PGM$
PRINT #1, "Menu"
CLOSE
SYSTEM
Ignore: RESUME NEXT
Posts: 1,688
Threads: 119
Joined: Jun 2003
batchs... don't remind me about them. some script kiddy figured it'd be funny to make a batch and send it to my brother... I spent all night trying to clean it up. :lol:
Jumping Jahoolipers!