VOGONS


First post, by boxgnome

User metadata
Rank Newbie
Rank
Newbie

Hi,

A newbie here, but using DosBox for sometime. I created a autoexec script within the dosbox-0.74.conf file for creating a quick user interface menu for choosing and running DOS programs. The script below currently allows for up to 60 individual programs, although I only have the first 15 defined (page 1). I have run into the problem of a size limit of characters allowed in the autoexec section where if I exceed the limit (somewhere around 4000 characters, the script wont run.

So, can someone suggest a workaround (other than calling another batch file or getting data from an external file source)? And can the DosBox author consider a fix in buffer size for a future release?

Here is the script file, feel free to use and modify for your own purposes:
(note1) pasting the code has striped out the spaces and will affect proper formatting if you copy and paste from the posted code below- refer to my .conf file which I have attached
(note2) most variable name were kept short to conserve bytes. The PRG variable is used both for the name of the program directory and the program executable, to keep it simple in the :START execution section.

[autoexec]
@MOUNT -U C
@CLS
:DISP1
@SET P1=DUKE NUKEM I EPISODE ONE: "SHRAPNEL CITY"
@SET P2=DUKE NUKEM I EPISODE TWO: "MISSION: MOONBASE"
@SET P3=DUKE NUKEM I EPISODE THREE: "TRAPPED IN THE FUTURE!"
@SET P4=DUKE NUKEM II EPISODES 1,2,3 AND 4
@SET P5=DUKE NUKEM 3D EPISODES 1,2 AND 3
@SET P6=RAPTOR
@SET P7=REALMS OF CHAOS
@SET P8=RISE OF THE TRIAD
@SET P9=TERMINAL VELOCITY
@SET PA=WACKY WHEELS
@SET PB=COLOSSAL CAVE
@SET PC=ASTERIODS
@SET PD=CENTIPEDE
@SET PE=TURBO PASCAL 6
@SET PF=TURBO PASCAL 7
@SET PG=1
@GOTO DISPLAY
:DISP2
@SET P1=
@SET P2=
@SET P3=
@SET P4=
@SET P5=
@SET P6=
@SET P7=
@SET P8=
@SET P9=
@SET PA=
@SET PB=
@SET PC=
@SET PD=
@SET PE=
@SET PF=
@SET PG=2
@GOTO DISPLAY
:DISP3
@SET P1=
@SET P2=
@SET P3=
@SET P4=
@SET P5=
@SET P6=
@SET P7=
@SET P8=
@SET P9=
@SET PA=
@SET PB=
@SET PC=
@SET PD=
@SET PE=
@SET PF=
@SET PG=3
@GOTO DISPLAY
:DISP4
@SET P1=
@SET P2=
@SET P3=
@SET P4=
@SET P5=
@SET P6=
@SET P7=
@SET P8=
@SET P9=
@SET PA=
@SET PB=
@SET PC=
@SET PD=
@SET PE=
@SET PF=
@SET PG=4
:DISPLAY
ECHO. [1;37;44m
@CLS
@ECHO OFF
ECHO.[2J WELCOME TO THE CLASSIC DOS PROGRAMS!
ECHO. SELECT A PROGRAM
ECHO. _________________________________________________________________
ECHO.
ECHO. [1] %P1%
ECHO. [2] %P2%
ECHO. [3] %P3%
ECHO. [4] %P4%
ECHO. [5] %P5%
ECHO. [6] %P6%
ECHO. [7] %P7%
ECHO. [8] %P8%
ECHO. [9] %P9%
ECHO. [A] %PA%
ECHO. %PB%
ECHO. [C] %PC%
ECHO. [D] %PD%
ECHO. [E] %PE%
ECHO. [F] %PF%
ECHO.
ECHO. More options [X] Exit [Z] Command Line
ECHO.
ECHO. ___________________________ Page %PG% of 4 ___________________________
ECHO.
@CHOICE /C:123456789ABCDEFMXZ /N PRESS A [KEY] TO CHOOSE...%1
@SET EL==ERRORLEVEL
@SET PRG==""
@IF %EL%==18 GOTO END
@IF %EL%==17 EXIT
@IF NOT %EL%==16 GOTO LOAD%PG%
@IF %PG%==4 GOTO DISP1
@IF %PG%==3 GOTO DISP4
@IF %PG%==2 GOTO DISP3
@IF %PG%==1 GOTO DISP2
:LOAD1
@IF %EL%==1 SET PRG=DN1
@IF %EL%==2 SET PRG=DN2
@IF %EL%==3 SET PRG=DN3
@IF %EL%==4 SET PRG=nukem2
@IF %EL%==5 SET PRG=duke3d
@IF %EL%==6 SET PRG=RAP
@IF %EL%==7 SET PRG=ROCSW
@IF %EL%==8 SET PRG=ROTT
@IF %EL%==9 SET PRG=TV
@IF %EL%==10 SET PRG=WW
@IF %EL%==11 SET PRG=ADVENTURE
@IF %EL%==12 SET PRG=
@IF %EL%==13 SET PRG=
@IF %EL%==14 SET PRG=TP6
@IF %EL%==15 SET PRG=TP7
@GOTO START
:LOAD2
@IF %EL%==1 SET PRG=DN1
@IF %EL%==2 SET PRG=DN2
@IF %EL%==3 SET PRG=DN3
@IF %EL%==4 SET PRG=nukem2
@IF %EL%==5 SET PRG=duke3d
@IF %EL%==6 SET PRG=RAP
@IF %EL%==7 SET PRG=ROCSW
@IF %EL%==8 SET PRG=ROTT
@IF %EL%==9 SET PRG=TV
@IF %EL%==10 SET PRG=WW
@IF %EL%==11 SET PRG=ADVENTURE
@IF %EL%==12 SET PRG=
@IF %EL%==13 SET PRG=
@IF %EL%==14 SET PRG=TP6
@IF %EL%==15 SET PRG=TP7
@GOTO START
:LOAD3
@IF %EL%==1 SET PRG=DN1
@IF %EL%==2 SET PRG=DN2
@IF %EL%==3 SET PRG=DN3
@IF %EL%==4 SET PRG=nukem2
@IF %EL%==5 SET PRG=duke3d
@IF %EL%==6 SET PRG=RAP
@IF %EL%==7 SET PRG=ROCSW
@IF %EL%==8 SET PRG=ROTT
@IF %EL%==9 SET PRG=TV
@IF %EL%==10 SET PRG=WW
@IF %EL%==11 SET PRG=ADVENTURE
@IF %EL%==12 SET PRG=
@IF %EL%==13 SET PRG=
@IF %EL%==14 SET PRG=TP6
@IF %EL%==15 SET PRG=TP7
:LOAD4
@IF %EL%==1 SET PRG=DN1
@IF %EL%==2 SET PRG=DN2
@IF %EL%==3 SET PRG=DN3
@IF %EL%==4 SET PRG=nukem2
@IF %EL%==5 SET PRG=duke3d
@IF %EL%==6 SET PRG=RAP
@IF %EL%==7 SET PRG=ROCSW
@IF %EL%==8 SET PRG=ROTT
@IF %EL%==9 SET PRG=TV
@IF %EL%==10 SET PRG=WW
@IF %EL%==11 SET PRG=ADVENTURE
@IF %EL%==12 SET PRG=
@IF %EL%==13 SET PRG=
@IF %EL%==14 SET PRG=TP6
@IF %EL%==15 SET PRG=TP7
:START
@CLS
INTRO SPECIAL
ECHO.
ECHO.
@PAUSE
@CLS
@MOUNT c C:\DOS_PROGRAMS\%PRG%
@C:
@%PRG%.EXE
@CLS
@MOUNT -U C
GOTO DISP%PG%
:END
CLS
ECHO.[1;37;40m
@MOUNT -U C

Reply 1 of 9, by Gamecollector

User metadata
Rank Oldbie
Rank
Oldbie

.bat files are yours friends.

Asus P4P800 SE/Pentium4 3.2E/2 Gb DDR400B,
Radeon HD3850 Agp (Sapphire), Catalyst 14.4 (XpProSp3).
Voodoo2 12 MB SLI, Win2k drivers 1.02.00 (XpProSp3).

Reply 2 of 9, by boxgnome

User metadata
Rank Newbie
Rank
Newbie

Yep, looks like I'll have to run it as a separate .bat file. For my needs, it would of been nice to keep it all inside of the .conf file.

Reply 3 of 9, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

4000 chars is indeed a bit much. Currently the buffer is 1k, it's easy changeable . but ideally the buffer would be dynamicly created.

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

Reply 4 of 9, by boxgnome

User metadata
Rank Newbie
Rank
Newbie

Hi Qbix

First, thank you for this program. Really is kinda fun going back in time playing with some of the oldie but goodies.

Yes, I suppose 4K is large, but I've seen .bat files much much larger (and more complex) back in the day. I made the presumption that I would have plent of room to add whatever number of lines/characters I needed. I could easily whip up a front-end in Perl, Python, or any decent DB application to do what I want, but I wanted to stay within the DOS theme of things. Not a problem now, as I am now calling it from an external .bat file which is working fine. Now, I can add a couple of hundred "slots" easily for the selection menu, but 60 for now is more than enough. Plan to add some more bells and whistles - all for fun, and will post when completed.

Reply 5 of 9, by Jayden Hawke

User metadata
Rank Newbie
Rank
Newbie

Rewrite your program using for loops to build an array. This can be smaller (especially if you don't use full words for variables like I tend to) and has no practical limit to the number of elements it can handle. As an example here is part of my minecraft multi-build front-end (full download at the bottom) that I wrote to manage differently modded builds.

SET count=0
FOR /D %%F IN (*) DO (
SET /A count+=1
)
SET /A countC=!count!/5+10
SET /A column=!count!/5+1
:ARRAY_BUILD
SET index=1
FOR /D %%G IN ("*") DO (
SET file!index!=%%G
SET index!index!=!index!
SET disp!index!=[%%G]
SET /A index+=1
)
GOTO :EOF

And to display the menu as a set of 5 vertical numbered columns:

:BUILD_MENU
SET countC=%1
MODE con:cols=125 lines=!countC!
ECHO/Available Builds
ECHO(
SET index=1
FOR /D %%G IN ("*") DO (
SET file!index!=%%G
SET index!index!=!index!
SET disp!index!=[%%G]
SET /A index+=1
)
SET countB=0
SET index0=0
SET disp0=[Main_Menu]
FOR /L %%H IN (1,1,!column!) DO (
SET countA=0
FOR /L %%I IN (0,1,4) DO (
SET /A indexA=!column!*!countA!+!countB!
CALL SET indexB=%%index!indexA!%%
IF !indexB! LSS 10 (
SET indexA!countA!= !indexB! -
) ELSE (
IF !indexB! LSS 100 (
SET indexA!countA!= !indexB! -
) ELSE (
SET indexA!countA!=!indexB! -
)
)
IF /I !indexA! GTR !count! (
SET "indexA4= "
SET "baseA= "
) ELSE (
CALL :DELIM %%disp!indexA!%% baseA
)
SET dispA!countA!=!baseA!
SET /A countA+=1
)
ECHO/!indexA0!!dispA0! !indexA1!!dispA1! !indexA2!!dispA2! !indexA3!!dispA3! !indexA4!!dispA4!
SET /A countB+=1
)
ECHO(
:BUILD_INPUT
CALL :INPUT file selection BUILD_INPUT
CALL SET %2=%%file%selection%%%
IF %selection%==0 (
GOTO INPUT_HOME
)
ECHO(
ECHO/Selected Version Name: !file%selection%!
CALL :DELAY
IF EXIST ".\!file%selection%!" (
SET "APPDATA=.\!file%selection%!"
) ELSE (
ECHO/Folder Not Found
CALL :DELAY
GOTO BUILD_INPUT
)

:DELAY
Show last 37 lines
ECHO/Wscript.Sleep %delay%> sleep.vbs
START /w wscript.exe sleep.vbs
DEL sleep.vbs
GOTO :EOF

:DELIM
SET length=0
SET string=%~1
SET baseB=%1
IF NOT DEFINED string (
GOTO :EOF
)
SET string=%string:"=.%987654321
:LOOP1
IF NOT "%string:~18%"=="" (
SET string=%string:~9%
SET /A length+=9
GOTO LOOP1
)
SET /A charS=%length%+%string:~9,1%
IF %selectionA%==4 (
SET %2=%charS%
GOTO :EOF
)
SET /A charS=18-%charS%
SET /A result=!charS!%%2
IF %result% EQU 1 (
SET baseB=!baseB!!space!
SET /A charS-=1
)
FOR /L %%J IN (!charS!,-2,2) DO (
SET baseB=!baseB!!space!!space!
SET /A charS-=2
)
SET %2=%baseB%
GOTO :EOF

What this does is go through the base folder and takes every folder name and stores it in a ascending variable structure e.g. folder1 folder2 folder3 Note that the menu names are based off of the folder name. However, you could reduce the number of columns to 3 and then store the proper name in a config file in the individual game folder that the array then calls each loop when it builds the menu.

Screenshot
menu-1.png

And here is the actual download.

Last edited by Jayden Hawke on 2012-09-05, 10:47. Edited 2 times in total.

Reply 6 of 9, by aqrit

User metadata
Rank Member
Rank
Member

hint: Use the code tag for code.

FOR /D %%F IN (*) DO (
SET /A count+=1
)

Reply 7 of 9, by Jayden Hawke

User metadata
Rank Newbie
Rank
Newbie

I see. Thanx.
Damn, I don't see an edit button.

Reply 8 of 9, by bloodbat

User metadata
Rank Oldbie
Rank
Oldbie

It looks like a circle, small, next to the quotes.

Reply 9 of 9, by Jayden Hawke

User metadata
Rank Newbie
Rank
Newbie

And fixed