Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everybody!
I have to make a batch program that will give a choice to the user:
press enter to restore or escape to backupThose are the only two keys usable. How do I make this program. I tried with set/p and errorlevels, cant do it. Can anyone help? Thanks!

http://www.computing.net/programmin...
It is the disadvantaged who habitually elect Democrats on the belief of personal change---
yet they remain disadvantaged.

The following batch solves your assignment, but I doubt you can get any help from it
@echo off
set de=ASK.TXT
type NUL > %de%
echo.AAAAAAAAAAAA> %de:~0,-4%.COM:: [Assembly_By_Debug]
echo.N %de:~0,-4%.COM>>%de%
echo.A 0100>>%de%
echo.MOV AH,08>>%de%
echo.INT 21>>%de%
echo.CMP AL,00>>%de%
echo.JNZ 010A>>%de%
echo.INT 21>>%de%
echo.MOV AH,4C>>%de%
echo.INT 21>>%de%
echo.>>%de%
echo.W>>%de%
echo.Q>>%de%
:: [End_Of_Assembly]debug %de:~0,-4%.COM < %de% > NUL
Echo.
echo. [ENTER] for RESTORE
echo. [ESCAPE] for BACKUP
echo.
:LOOP
%de:~0,-4%.COM
if %errorlevel% equ 13 goto :RESTORE
if %errorlevel% equ 27 goto :BACKUP
goto :LOOP:RESTORE
echo.RESTORE
goto :END
:BACKUP
echo.BACKUP
goto :END:END
del %de%.*
set de=
:: [End_Of_Batch]

Thanks IVO it works! BUT...
What does this mean?
echo.AAAAAAAAAAAA> %de:~0,-4%.COM
My best guess would be echo AAAAAAAAAAA in the file called %de at position 0 -4%.com????

Also where can I get more information about how to use debug and all of those echo a,echo n, etc functions?
thanks

See response number 1 for all your programming information... forums usually work best when the proper protocols are followed
There is no such thing as Health Food... just Health Fanatics!

To illy
About the DEBUG command take a look at
http://technet.microsoft.com/en-us/...
The statement
echo.AAAAAAAAAAAA> %de:~0,-4%.COM
creates the file ASK.COM of lenght 14 bytes (12 As and a CR/LF), exactly the size Debug produces assembling ASK.TXT. You can't write the contents of memory without a file equal or greater to the interval to be saved.
The %de:~0,-4% is the substring from %de% with the last four position stripped away. To know about type Set /? at prompt.
The echo sequence creates the text file to be interpreted by Debug: it declares the file to be modified (N), codes the instructions (A), saves them (W) and quits (Q).
the statement
debug ASK.COM < ASK.TXT > NUL
forces Debug to read its commands from ASK.TXT, to suppress the output messages (redirected to NUL) and to operate on the ASK.COM file.
The script can be less cumbersome but I coded it just on the fly.
To Ewen,
you are right, but despite its (apparently) complexity what posted is just a plain batch and many scripts of this kind are hosted in this Forum.
My way is to help first of all.

![]() |
Reformatting Computer
|
Dell Drivers
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |