Discussion:
Menu?
(too old to reply)
Rick_C
2008-03-29 20:14:20 UTC
Permalink
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?

Thanks

Rick
Jawade
2008-03-29 20:34:56 UTC
Permalink
In article <wqxHj.18695$***@newsfe6-win.ntli.net>, Rick_C <***@ntlworld.com>
says...
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
The old filebrowser LIST.COM from Vernon D. Buerg can do that.
--
Met vriendelijke groeten, Jawade. Weer veel vernieuwd!
http://jawade.nl/ Met een mirror op http://jawade.fortunecity.com/
Bootmanager (+Vista +Linux), ClrMBR, DiskEdit (+Linux), POP3lezer,
DOS-Filebrowser, Kalender, Webtellers en IP-log, USB-stick tester.
A***@NOT.AT.Arargh.com
2008-03-29 23:42:58 UTC
Permalink
Post by Jawade
says...
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
The old filebrowser LIST.COM from Vernon D. Buerg can do that.
Likewise the old File Manager from Wordperfect Library.

Add more here :-)
--
ArarghMail803 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the extra stuff from the reply address.
Herbert Kleebauer
2008-03-30 00:53:24 UTC
Permalink
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
In Win2k/XP/Vista this is trivial, type

for /?
start /?
set /?

for more information.

In pure DOS or Win9x this is more complicated. Here one way to do it:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
if [%1]==[1] goto :sub1
if [%1]==[2] goto :sub2
set n=a>_2.bat
echo %0 2 >>_2.bat

echo :loop>_1.bat
echo choice /n /cabcdefghijklmnopqrstuvwxyz0 [a-z, 0 for exit]:>>_1.bat
for %%i in (*.txt) do call %0 1 %%i
echo.
echo if not errorlevel 27 goto loop>>_1.bat
call _1.bat
if exist _1.bat del _1.bat
if exist _2.bat del _2.bat
goto eof

:sub1
set m=%2
_2.bat
:sub2
echo.>_2.bat
if [%n%]==[a] echo set n=b>>_2.bat
if [%n%]==[a] echo if errorlevel 1 if not errorlevel 2 edit %m% >>_1.bat
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.bat
if [%n%]==[c] echo set n=d>>_2.bat
if [%n%]==[c] echo if errorlevel 3 if not errorlevel 4 edit %m% >>_1.bat
if [%n%]==[d] echo set n=e>>_2.bat
if [%n%]==[d] echo if errorlevel 4 if not errorlevel 5 edit %m% >>_1.bat
if [%n%]==[e] echo set n=e>>_2.bat
if [%n%]==[e] echo if errorlevel 5 if not errorlevel 6 edit %m% >>_1.bat
if [%n%]==[f] echo set n=e>>_2.bat
if [%n%]==[f] echo if errorlevel 6 if not errorlevel 7 edit %m% >>_1.bat
if [%n%]==[g] echo set n=e>>_2.bat
if [%n%]==[g] echo if errorlevel 7 if not errorlevel 8 edit %m% >>_1.bat
if [%n%]==[h] echo set n=e>>_2.bat
if [%n%]==[h] echo if errorlevel 8 if not errorlevel 9 edit %m% >>_1.bat
if [%n%]==[i] echo set n=e>>_2.bat
if [%n%]==[i] echo if errorlevel 9 if not errorlevel 10 edit %m% >>_1.bat
if [%n%]==[j] echo set n=e>>_2.bat
if [%n%]==[j] echo if errorlevel 10 if not errorlevel 11 edit %m% >>_1.bat
if [%n%]==[k] echo set n=e>>_2.bat
if [%n%]==[k] echo if errorlevel 11 if not errorlevel 12 edit %m% >>_1.bat
if [%n%]==[l] echo set n=e>>_2.bat
if [%n%]==[l] echo if errorlevel 12 if not errorlevel 13 edit %m% >>_1.bat
if [%n%]==[m] echo set n=e>>_2.bat
if [%n%]==[m] echo if errorlevel 13 if not errorlevel 14 edit %m% >>_1.bat
if [%n%]==[n] echo set n=e>>_2.bat
if [%n%]==[n] echo if errorlevel 14 if not errorlevel 15 edit %m% >>_1.bat
if [%n%]==[o] echo set n=e>>_2.bat
if [%n%]==[o] echo if errorlevel 15 if not errorlevel 16 edit %m% >>_1.bat
if [%n%]==[p] echo set n=e>>_2.bat
if [%n%]==[p] echo if errorlevel 16 if not errorlevel 17 edit %m% >>_1.bat
if [%n%]==[q] echo set n=e>>_2.bat
if [%n%]==[q] echo if errorlevel 17 if not errorlevel 18 edit %m% >>_1.bat
if [%n%]==[r] echo set n=e>>_2.bat
if [%n%]==[r] echo if errorlevel 18 if not errorlevel 19 edit %m% >>_1.bat
if [%n%]==[s] echo set n=e>>_2.bat
if [%n%]==[s] echo if errorlevel 19 if not errorlevel 20 edit %m% >>_1.bat
if [%n%]==[t] echo set n=e>>_2.bat
if [%n%]==[t] echo if errorlevel 20 if not errorlevel 21 edit %m% >>_1.bat
if [%n%]==[u] echo set n=e>>_2.bat
if [%n%]==[u] echo if errorlevel 21 if not errorlevel 22 edit %m% >>_1.bat
if [%n%]==[v] echo set n=e>>_2.bat
if [%n%]==[v] echo if errorlevel 22 if not errorlevel 23 edit %m% >>_1.bat
if [%n%]==[w] echo set n=e>>_2.bat
if [%n%]==[w] echo if errorlevel 23 if not errorlevel 24 edit %m% >>_1.bat
if [%n%]==[x] echo set n=e>>_2.bat
if [%n%]==[x] echo if errorlevel 24 if not errorlevel 25 edit %m% >>_1.bat
if [%n%]==[y] echo set n=e>>_2.bat
if [%n%]==[y] echo if errorlevel 25 if not errorlevel 26 edit %m% >>_1.bat
if [%n%]==[z] echo set n=e>>_2.bat
if [%n%]==[z] echo if errorlevel 26 if not errorlevel 27 edit %m% >>_1.bat
echo %0 2 >>_2.bat
echo [%n%] %m%
:eof
Richard Bonner
2008-04-01 12:51:11 UTC
Permalink
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
Rick
*** As has already been suggested, I would use a file browser. I use PC
TOOLS' "VIEW".

With no viewer, one could use the DIR and TYPE commands. If scrolling
the files is required, one could use "EDIT /R".

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
Rick
2008-04-02 00:31:43 UTC
Permalink
Do you think XTREEGOLD/DOSSHELL would be ok or a bit over the top?
Can you run more than one prog in XTG?

Edit cannot open some of the text files I have - 'out of memory'

Those batch file the other guy wrote just emptied themselves. Think the clue
was in the If exist then del lines?

I must look into batch programming sometime.

Rick
Post by Richard Bonner
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
Rick
*** As has already been suggested, I would use a file browser. I use PC
TOOLS' "VIEW".
With no viewer, one could use the DIR and TYPE commands. If scrolling
the files is required, one could use "EDIT /R".
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
Herbert Kleebauer
2008-04-02 08:14:26 UTC
Permalink
Post by Rick
Those batch file the other guy wrote just emptied themselves. Think the clue
was in the If exist then del lines?
Which OS do you use? The batch doesn't work in W2k/XP (there is mo choice command),
but as I said, with this OSs it is trivial. The posted code was tested with
Win98 and DOS 6.

Make a new directory, for example c:\test and save the posted code as txtmenu.bat
in this directory. Then create a few text files (text1.txt, text2.txt, text3.txt).
CD to this directory and type "dir", you should get:


TXTMENU BAT 3.364 02.04.08 9:04
TEXT1 TXT 3 02.04.08 9:04
TEXT2 TXT 3 02.04.08 9:05
TEXT3 TXT 3 02.04.08 9:05
6 Datei(en) 3.373 Byte
401.801.216 Byte frei


Now type "txtmenu" and you should get:

C:\TEST> textmenu
[a] TEXT1.TXT
[b] TEXT2.TXT
[c] TEXT3.TXT

[a-z, 0 for exit]:

If you press "b" the file TEXT2.TXT is opened with the editor.

If it doesn't work for you, please post a screen shoot of the output.
Rick
2008-04-02 15:08:39 UTC
Permalink
Sorry misunderstood how to use the files.

Now all I get is bad command or file name displayed continously.

Running it with the 'command /y /k gives '

It goes throuigh every line once then displays :-

[a] 08thes~1.txt
[Y/N]?nu1 1 09sata~1.txt (on pressing Y the nu changes toYu)
echo off [Y/N]?Y
if [1]==[1] goto :sub1 [Y/N]?Y
goto :sub1 [Y/N]
set m=09sata~1.txt [Y/N]?Y
_2.bat [Y/N]?Y
Y [Y/N]?Y
Bad command or file name
set n=b [Y/N]?Y
menu1 2 [Y/N]?Y
echo off [Y/N]?Y

then runs through every line again until it comes to that line 'Y [Y/N]?
then gives bad command or file name.

Thanks


Rick
Post by Herbert Kleebauer
Post by Rick
Those batch file the other guy wrote just emptied themselves. Think the clue
was in the If exist then del lines?
Which OS do you use? The batch doesn't work in W2k/XP (there is mo choice command),
but as I said, with this OSs it is trivial. The posted code was tested with
Win98 and DOS 6.
Make a new directory, for example c:\test and save the posted code as txtmenu.bat
in this directory. Then create a few text files (text1.txt, text2.txt, text3.txt).
TXTMENU BAT 3.364 02.04.08 9:04
TEXT1 TXT 3 02.04.08 9:04
TEXT2 TXT 3 02.04.08 9:05
TEXT3 TXT 3 02.04.08 9:05
6 Datei(en) 3.373 Byte
401.801.216 Byte frei
C:\TEST> textmenu
[a] TEXT1.TXT
[b] TEXT2.TXT
[c] TEXT3.TXT
If you press "b" the file TEXT2.TXT is opened with the editor.
If it doesn't work for you, please post a screen shoot of the output.
Herbert Kleebauer
2008-04-02 15:48:21 UTC
Permalink
Post by Rick
Sorry misunderstood how to use the files.
Which OS do you use?
Post by Rick
Now all I get is bad command or file name displayed continously.
Running it with the 'command /y /k gives '
Seems your single step Y is redirected to a file. Just run it normaly,
but remove the first line "@echo off", then you should see which command
is not found.

Also remove the two lines:

if exist _1.bat del _1.bat
if exist _2.bat del _2.bat

What is the content of this two files after you stop the batch?


Are you sure there wasn't a copy and paste error of the code (maybe a line
wrap). Are there spaces in your file names? Here it works in Win98 and DOS6.
Rick
2008-04-02 20:08:19 UTC
Permalink
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21

Error seems to be on the choice line,
it displays :-
TESTM>choice /n /c:abc0 [a-c, 0 for exit]:
Bad command or file name
TESTM>if not errorlevel 27 goto loop

Those actual lines are:-
echo choice /n /c:abcdefghijklmnopqrstuvwxyz0 [a-z, 0 for exit]:>>_1.bat
for %%i in (*.txt) do call %0 1%%i

echo.
echo if not errorlevel 27 goto loop>>_1.bat
call _1.bat

rem
rem
goto eof



contents of _1.bat

:loop
choice /n /c:abcdefghijklmnopqrstuvwxyz0 [a-c, 0 for exit]:
if not errorlevel 27 goto loop
--------------------------------------------
Contents of _2.bat

menu12



Thanks for you help.

Rick

This type of menu is just what i want. I assume that the (*.txt) ensures
that it only shows txt files or whatever extention is in the brackets.
Post by Herbert Kleebauer
Post by Rick
Sorry misunderstood how to use the files.
Which OS do you use?
Post by Rick
Now all I get is bad command or file name displayed continously.
Running it with the 'command /y /k gives '
Seems your single step Y is redirected to a file. Just run it normaly,
is not found.
if exist _1.bat del _1.bat
if exist _2.bat del _2.bat
What is the content of this two files after you stop the batch?
Are you sure there wasn't a copy and paste error of the code (maybe a line
wrap). Are there spaces in your file names? Here it works in Win98 and DOS6.
Sjouke Burry
2008-04-02 20:49:50 UTC
Permalink
Post by Rick
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21
Error seems to be on the choice line,
it displays :-
Bad command or file name
TESTM>if not errorlevel 27 goto loop
Choice is a program,(CHOICE.COM) and if that is not found in the
path, it fails.
It is part of dos6.22, and its help says from dos4.00 up
Before that Norton utilitys had something like it.
There is also a version in c_snippets.
Also google turned up for the below search phrase:
choice.com download
a lot,reference 2 looks oke.
Rick
2008-04-02 22:11:15 UTC
Permalink
Thanks all - it now works.

Can anyone explain what exactly these lines do?

if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.bat
edit means open edit.com, but the rest I don't know.

Rick
Post by Sjouke Burry
Post by Rick
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21
Error seems to be on the choice line,
it displays :-
Bad command or file name
TESTM>if not errorlevel 27 goto loop
Choice is a program,(CHOICE.COM) and if that is not found in the
path, it fails.
It is part of dos6.22, and its help says from dos4.00 up
Before that Norton utilitys had something like it.
There is also a version in c_snippets.
choice.com download
a lot,reference 2 looks oke.
Rick
2008-04-03 00:07:36 UTC
Permalink
When I use it ( The Menu batch file) with any prog except 'edit.com' the
menu doesn't reappear when you close the text editor.
Unfortunately a lot of my text files are 400k+ and edit won't open them.
Type won't work because the batch file won't accept the '| more' command
I've tried Word for DOS, WP5.1 for DOS, Vi, Elvis, vile. Anyone know of a
basic text editor similar to edit.com that opens large text files, or how I
can alter the batch file so that it redisplays the menu. I think that it is
only edit.com that totally clears the screen when it has finished.



Rick
Post by Rick
Thanks all - it now works.
Can anyone explain what exactly these lines do?
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.bat
edit means open edit.com, but the rest I don't know.
Rick
Post by Sjouke Burry
Post by Rick
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21
Error seems to be on the choice line,
it displays :-
Bad command or file name
TESTM>if not errorlevel 27 goto loop
Choice is a program,(CHOICE.COM) and if that is not found in the
path, it fails.
It is part of dos6.22, and its help says from dos4.00 up
Before that Norton utilitys had something like it.
There is also a version in c_snippets.
choice.com download
a lot,reference 2 looks oke.
Sjouke Burry
2008-04-03 00:18:09 UTC
Permalink
Post by Rick
When I use it ( The Menu batch file) with any prog except 'edit.com' the
menu doesn't reappear when you close the text editor.
Unfortunately a lot of my text files are 400k+ and edit won't open them.
Type won't work because the batch file won't accept the '| more' command
I've tried Word for DOS, WP5.1 for DOS, Vi, Elvis, vile. Anyone know of a
basic text editor similar to edit.com that opens large text files, or how I
can alter the batch file so that it redisplays the menu. I think that it is
only edit.com that totally clears the screen when it has finished.
Rick
Post by Rick
Thanks all - it now works.
Can anyone explain what exactly these lines do?
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.bat
edit means open edit.com, but the rest I don't know.
Rick
Post by Sjouke Burry
Post by Rick
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21
Error seems to be on the choice line,
it displays :-
Bad command or file name
TESTM>if not errorlevel 27 goto loop
Choice is a program,(CHOICE.COM) and if that is not found in the
path, it fails.
It is part of dos6.22, and its help says from dos4.00 up
Before that Norton utilitys had something like it.
There is also a version in c_snippets.
choice.com download
a lot,reference 2 looks oke.
Try : call program.exe(or com)......etc.........
to make sure you get back to the batch file, when "program" exits.
The call in front opens a new shell for the program, and
ensures return to the batch file.
Rick
2008-04-03 00:24:40 UTC
Permalink
Thanks for a quick reply - but it didn't work.
the screen is clear except for the 'choice menu'

Rick
Post by Sjouke Burry
Post by Rick
When I use it ( The Menu batch file) with any prog except 'edit.com' the
menu doesn't reappear when you close the text editor.
Unfortunately a lot of my text files are 400k+ and edit won't open them.
Type won't work because the batch file won't accept the '| more' command
I've tried Word for DOS, WP5.1 for DOS, Vi, Elvis, vile. Anyone know of
a basic text editor similar to edit.com that opens large text files, or
how I can alter the batch file so that it redisplays the menu. I think
that it is only edit.com that totally clears the screen when it has
finished.
Rick
Post by Rick
Thanks all - it now works.
Can anyone explain what exactly these lines do?
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m%
Post by Sjouke Burry
Post by Herbert Kleebauer
_1.bat
edit means open edit.com, but the rest I don't know.
Rick
Post by Sjouke Burry
Post by Herbert Kleebauer
Post by Herbert Kleebauer
Which OS do you use?
Dos 6.21
Error seems to be on the choice line,
it displays :-
Bad command or file name
TESTM>if not errorlevel 27 goto loop
Choice is a program,(CHOICE.COM) and if that is not found in the
path, it fails.
It is part of dos6.22, and its help says from dos4.00 up
Before that Norton utilitys had something like it.
There is also a version in c_snippets.
choice.com download
a lot,reference 2 looks oke.
Try : call program.exe(or com)......etc.........
to make sure you get back to the batch file, when "program" exits.
The call in front opens a new shell for the program, and
ensures return to the batch file.
Herbert Kleebauer
2008-04-03 09:07:36 UTC
Permalink
Post by Rick
Thanks for a quick reply - but it didn't work.
the screen is clear except for the 'choice menu'
Use this version:
(repace "edit" with the name of your editor)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
if [%1]==[1] goto :sub1
if [%1]==[2] goto :sub2
set n=a>_2.bat
echo %0 2 >>_2.bat

echo :loop>_1.bat
echo cls>>_1.bat
for %%i in (*.txt) do call %0 1 %%i
echo echo.>>_1.bat
echo choice /n /cabcdefghijklmnopqrstuvwxyz0 [a-z, 0 for exit]:>>_1.bat
type _1.___>>_1.bat
echo if not errorlevel 27 goto loop>>_1.bat
call _1.bat
if exist _1.___ del _1.___
if exist _1.bat del _1.bat
if exist _2.bat del _2.bat
goto eof

:sub1
set m=%2
_2.bat
:sub2
echo.>_2.bat
if [%n%]==[a] echo set n=b>>_2.bat
if [%n%]==[a] echo if errorlevel 1 if not errorlevel 2 edit %m% >>_1.___
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.___
if [%n%]==[c] echo set n=d>>_2.bat
if [%n%]==[c] echo if errorlevel 3 if not errorlevel 4 edit %m% >>_1.___
if [%n%]==[d] echo set n=e>>_2.bat
if [%n%]==[d] echo if errorlevel 4 if not errorlevel 5 edit %m% >>_1.___
if [%n%]==[e] echo set n=e>>_2.bat
if [%n%]==[e] echo if errorlevel 5 if not errorlevel 6 edit %m% >>_1.___
if [%n%]==[f] echo set n=e>>_2.bat
if [%n%]==[f] echo if errorlevel 6 if not errorlevel 7 edit %m% >>_1.___
if [%n%]==[g] echo set n=e>>_2.bat
if [%n%]==[g] echo if errorlevel 7 if not errorlevel 8 edit %m% >>_1.___
if [%n%]==[h] echo set n=e>>_2.bat
if [%n%]==[h] echo if errorlevel 8 if not errorlevel 9 edit %m% >>_1.___
if [%n%]==[i] echo set n=e>>_2.bat
if [%n%]==[i] echo if errorlevel 9 if not errorlevel 10 edit %m% >>_1.___
if [%n%]==[j] echo set n=e>>_2.bat
if [%n%]==[j] echo if errorlevel 10 if not errorlevel 11 edit %m% >>_1.___
if [%n%]==[k] echo set n=e>>_2.bat
if [%n%]==[k] echo if errorlevel 11 if not errorlevel 12 edit %m% >>_1.___
if [%n%]==[l] echo set n=e>>_2.bat
if [%n%]==[l] echo if errorlevel 12 if not errorlevel 13 edit %m% >>_1.___
if [%n%]==[m] echo set n=e>>_2.bat
if [%n%]==[m] echo if errorlevel 13 if not errorlevel 14 edit %m% >>_1.___
if [%n%]==[n] echo set n=e>>_2.bat
if [%n%]==[n] echo if errorlevel 14 if not errorlevel 15 edit %m% >>_1.___
if [%n%]==[o] echo set n=e>>_2.bat
if [%n%]==[o] echo if errorlevel 15 if not errorlevel 16 edit %m% >>_1.___
if [%n%]==[p] echo set n=e>>_2.bat
if [%n%]==[p] echo if errorlevel 16 if not errorlevel 17 edit %m% >>_1.___
if [%n%]==[q] echo set n=e>>_2.bat
if [%n%]==[q] echo if errorlevel 17 if not errorlevel 18 edit %m% >>_1.___
if [%n%]==[r] echo set n=e>>_2.bat
if [%n%]==[r] echo if errorlevel 18 if not errorlevel 19 edit %m% >>_1.___
if [%n%]==[s] echo set n=e>>_2.bat
if [%n%]==[s] echo if errorlevel 19 if not errorlevel 20 edit %m% >>_1.___
if [%n%]==[t] echo set n=e>>_2.bat
if [%n%]==[t] echo if errorlevel 20 if not errorlevel 21 edit %m% >>_1.___
if [%n%]==[u] echo set n=e>>_2.bat
if [%n%]==[u] echo if errorlevel 21 if not errorlevel 22 edit %m% >>_1.___
if [%n%]==[v] echo set n=e>>_2.bat
if [%n%]==[v] echo if errorlevel 22 if not errorlevel 23 edit %m% >>_1.___
if [%n%]==[w] echo set n=e>>_2.bat
if [%n%]==[w] echo if errorlevel 23 if not errorlevel 24 edit %m% >>_1.___
if [%n%]==[x] echo set n=e>>_2.bat
if [%n%]==[x] echo if errorlevel 24 if not errorlevel 25 edit %m% >>_1.___
if [%n%]==[y] echo set n=e>>_2.bat
if [%n%]==[y] echo if errorlevel 25 if not errorlevel 26 edit %m% >>_1.___
if [%n%]==[z] echo set n=e>>_2.bat
if [%n%]==[z] echo if errorlevel 26 if not errorlevel 27 edit %m% >>_1.___
echo %0 2 >>_2.bat
echo echo [%n%] %m%>>_1.bat
:eof
Rick
2008-04-03 22:06:20 UTC
Permalink
Thanks for a prompt solution.

I just have 1 more problem.

The batch file works ok with up to 4 files. Then every one after the 4th is
designated an [e] although pressing e does cause it to open the 5th one.
Could it be these lines?

if [%n%] ==[d] echo set n=e>>_2.bat

this is the 1st line where n=e. Every instance after this n=e right up to
if [%n%]==[z] then n=e.

could this be the problem?

Thanks

Rick

This menu system is just what I wanted.
Post by Herbert Kleebauer
Post by Rick
Thanks for a quick reply - but it didn't work.
the screen is clear except for the 'choice menu'
(repace "edit" with the name of your editor)
@echo off
if [%1]==[1] goto :sub1
if [%1]==[2] goto :sub2
set n=a>_2.bat
echo %0 2 >>_2.bat
echo :loop>_1.bat
echo cls>>_1.bat
for %%i in (*.txt) do call %0 1 %%i
echo echo.>>_1.bat
echo choice /n /cabcdefghijklmnopqrstuvwxyz0 [a-z, 0 for exit]:>>_1.bat
type _1.___>>_1.bat
echo if not errorlevel 27 goto loop>>_1.bat
call _1.bat
if exist _1.___ del _1.___
if exist _1.bat del _1.bat
if exist _2.bat del _2.bat
goto eof
:sub1
set m=%2
_2.bat
:sub2
echo.>_2.bat
if [%n%]==[a] echo set n=b>>_2.bat
if [%n%]==[a] echo if errorlevel 1 if not errorlevel 2 edit %m% >>_1.___
if [%n%]==[b] echo set n=c>>_2.bat
if [%n%]==[b] echo if errorlevel 2 if not errorlevel 3 edit %m% >>_1.___
if [%n%]==[c] echo set n=d>>_2.bat
if [%n%]==[c] echo if errorlevel 3 if not errorlevel 4 edit %m% >>_1.___
if [%n%]==[d] echo set n=e>>_2.bat
if [%n%]==[d] echo if errorlevel 4 if not errorlevel 5 edit %m% >>_1.___
if [%n%]==[e] echo set n=e>>_2.bat
if [%n%]==[e] echo if errorlevel 5 if not errorlevel 6 edit %m% >>_1.___
if [%n%]==[f] echo set n=e>>_2.bat
if [%n%]==[f] echo if errorlevel 6 if not errorlevel 7 edit %m% >>_1.___
if [%n%]==[g] echo set n=e>>_2.bat
if [%n%]==[g] echo if errorlevel 7 if not errorlevel 8 edit %m% >>_1.___
if [%n%]==[h] echo set n=e>>_2.bat
if [%n%]==[h] echo if errorlevel 8 if not errorlevel 9 edit %m% >>_1.___
if [%n%]==[i] echo set n=e>>_2.bat
if [%n%]==[i] echo if errorlevel 9 if not errorlevel 10 edit %m% >>_1.___
if [%n%]==[j] echo set n=e>>_2.bat
if [%n%]==[j] echo if errorlevel 10 if not errorlevel 11 edit %m% >>_1.___
if [%n%]==[k] echo set n=e>>_2.bat
if [%n%]==[k] echo if errorlevel 11 if not errorlevel 12 edit %m% >>_1.___
if [%n%]==[l] echo set n=e>>_2.bat
if [%n%]==[l] echo if errorlevel 12 if not errorlevel 13 edit %m% >>_1.___
if [%n%]==[m] echo set n=e>>_2.bat
if [%n%]==[m] echo if errorlevel 13 if not errorlevel 14 edit %m% >>_1.___
if [%n%]==[n] echo set n=e>>_2.bat
if [%n%]==[n] echo if errorlevel 14 if not errorlevel 15 edit %m% >>_1.___
if [%n%]==[o] echo set n=e>>_2.bat
if [%n%]==[o] echo if errorlevel 15 if not errorlevel 16 edit %m% >>_1.___
if [%n%]==[p] echo set n=e>>_2.bat
if [%n%]==[p] echo if errorlevel 16 if not errorlevel 17 edit %m% >>_1.___
if [%n%]==[q] echo set n=e>>_2.bat
if [%n%]==[q] echo if errorlevel 17 if not errorlevel 18 edit %m% >>_1.___
if [%n%]==[r] echo set n=e>>_2.bat
if [%n%]==[r] echo if errorlevel 18 if not errorlevel 19 edit %m% >>_1.___
if [%n%]==[s] echo set n=e>>_2.bat
if [%n%]==[s] echo if errorlevel 19 if not errorlevel 20 edit %m% >>_1.___
if [%n%]==[t] echo set n=e>>_2.bat
if [%n%]==[t] echo if errorlevel 20 if not errorlevel 21 edit %m% >>_1.___
if [%n%]==[u] echo set n=e>>_2.bat
if [%n%]==[u] echo if errorlevel 21 if not errorlevel 22 edit %m% >>_1.___
if [%n%]==[v] echo set n=e>>_2.bat
if [%n%]==[v] echo if errorlevel 22 if not errorlevel 23 edit %m% >>_1.___
if [%n%]==[w] echo set n=e>>_2.bat
if [%n%]==[w] echo if errorlevel 23 if not errorlevel 24 edit %m% >>_1.___
if [%n%]==[x] echo set n=e>>_2.bat
if [%n%]==[x] echo if errorlevel 24 if not errorlevel 25 edit %m% >>_1.___
if [%n%]==[y] echo set n=e>>_2.bat
if [%n%]==[y] echo if errorlevel 25 if not errorlevel 26 edit %m% >>_1.___
if [%n%]==[z] echo set n=e>>_2.bat
if [%n%]==[z] echo if errorlevel 26 if not errorlevel 27 edit %m% >>_1.___
echo %0 2 >>_2.bat
echo echo [%n%] %m%>>_1.bat
:eof
Herbert Kleebauer
2008-04-03 22:52:11 UTC
Permalink
Post by Rick
The batch file works ok with up to 4 files. Then every one after the 4th is
designated an [e] although pressing e does cause it to open the 5th one.
Could it be these lines?
if [%n%] ==[d] echo set n=e>>_2.bat
this is the 1st line where n=e. Every instance after this n=e right up to
if [%n%]==[z] then n=e.
Sorry, tested it only with three files. Change it to

if [%n%] ==[d] echo set n=e>>_2.bat
if [%n%] ==[e] echo set n=f>>_2.bat
if [%n%] ==[g] echo set n=h>>_2.bat
if [%n%] ==[h] echo set n=i>>_2.bat
:
:
Rick
2008-04-03 23:47:26 UTC
Permalink
Thanks it works ok now, but will the line :-

if [%n%] ==[h] echo set n=i>>_2.bat
interfere with the variable used earlier:-

for %%i in (*.txt) do call %0 1 %%i

Thanks

Rick
PS Am i correct in assuming you can get a batch file to display a list of
directories and then choose a directory to go into?
Post by Herbert Kleebauer
Post by Rick
The batch file works ok with up to 4 files. Then every one after the 4th is
designated an [e] although pressing e does cause it to open the 5th one.
Could it be these lines?
if [%n%] ==[d] echo set n=e>>_2.bat
this is the 1st line where n=e. Every instance after this n=e right up to
if [%n%]==[z] then n=e.
Sorry, tested it only with three files. Change it to
if [%n%] ==[d] echo set n=e>>_2.bat
if [%n%] ==[e] echo set n=f>>_2.bat
if [%n%] ==[g] echo set n=h>>_2.bat
if [%n%] ==[h] echo set n=i>>_2.bat
Herbert Kleebauer
2008-04-04 11:55:22 UTC
Permalink
Post by Rick
Thanks it works ok now, but will the line :-
if [%n%] ==[h] echo set n=i>>_2.bat
interfere with the variable used earlier:-
This is nothing but an echo command.
Post by Rick
for %%i in (*.txt) do call %0 1 %%i
Rick
PS Am i correct in assuming you can get a batch file to display a list of
directories and then choose a directory to go into?
That isn't worth the effort. Install the Norton Commander (or a free clone).
You won't be happy with DOS 6 without such a file manager. At least use
DOSSHELL (it's on the extra floppy of MS-DOS 6), but you really should
try to get the Norton Commander.
Robert Riebisch
2008-04-04 15:14:41 UTC
Permalink
Post by Herbert Kleebauer
try to get the Norton Commander.
Or any of these: http://www.bttr-software.de/links/#fileman
--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
Richard Bonner
2008-04-04 16:52:38 UTC
Permalink
Post by Rick
Post by Richard Bonner
Post by Rick_C
If I have a directory with a few text files how can I create a menu that
lists those files and I can open them from that menu, then return to that
menu when i've finished with a file?
Rick
*** As has already been suggested, I would use a file browser. I use PC
TOOLS' "VIEW".
With no viewer, one could use the DIR and TYPE commands. If scrolling
the files is required, one could use "EDIT /R".
Richard Bonner
Do you think XTREEGOLD/DOSSHELL would be ok or a bit over the top?
*** They would work fine. As for "over the top", the additional features
may make those programs more usable than just as file browsers.
Post by Rick
Can you run more than one prog in XTG?
*** I don't know. I shun shells and only ever used XTG once at a
friend's place.
Post by Rick
Edit cannot open some of the text files I have - 'out of memory'
*** Use version 2.0.026. It came with WIN 95.
Post by Rick
Those batch file the other guy wrote just emptied themselves. Think the clue
was in the If exist then del lines?
*** I don't know. You need to include the relevant part of his post.
With all the newsgroups I have and the fact that I often don't get back to
them for days, I can't remember what was said.
Post by Rick
I must look into batch programming sometime.
Rick
*** See:

http://www.chebucto.ca/~ak621/DOS/BatBasic.html


Richard Bonner
http://www.chebucto.ca/~ak621/DOS/


PS: Please don't top post.

Thanks

R.

Loading...