name confirm title confirm.com 1.2 ; Copyright: (c) 1998-2017 Roedy Green, Canadian Mind Products Comment | Written in Microsoft Assembler MASM 5.0 or OptAsm 1.61b Please report bugs and problems to: Roedy Green Canadian Mind Products #101 - 2536 Wark Street Victoria, BC Canada V8T 4G8 tel:(250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com Purpose ======= CONFIRM Ask user for Yes/No confirmation, Used in a bat file to set errorlevel to 0 if user answers Y, or 1 if NSyntax ====== @echo off echo Do you really want to do this dangerous thing? confirm.com If ERRORLEVEL 1 GoTo NO GoTo YES Note, no parameters or messages go on the confirm command line itself. Works under DOS, Win 3.1, Win95, Win 98, NT, W2K, XP, Vista, Windows 7-32 bit. For Windows 7 64-bit, you must use the confirm.exe C version instead. Version History =============== 1.0 1999-09-05 initial release 1.1 2009-03-12 add ANT build script 1.2 2010-01-30 now bundled with alternate C confirm.exe version for Windows 7 64-bit | ; End of comment. ;====== stack segment stack ; keep MS link happy by providing null stack stack ends ;============================================================== CODE segment PARA ; start off in code. ;============================================================== data segment word ; provide a separate DATA segment ; Even though it appears in the source ; before the code, it the COM file it YorNMsg label byte db 13,10,"Hit Y for yes, or N for no.",13,10,"$" YesMsg label byte db " Yes",13,10,"$" NoMsg label byte db " No",13,10,"$" BeepMsg label byte db 7,"$" data ends com group code,data assume CS:COM,DS:COM,ES:NOTHING org 100H Start: ; prompt user to hit Y or N lea dx,YorNMsg call say AGAIN: ; get char, wait, without echo. mov AX,0700h ; AH=07 signifies read char int 21h ; without Ctrl-C Ctrl-Break or cmp al,"Y" je YES cmp al,"y" je YES cmp al,"N" je NO cmp al,"n" je NO cmp al,27 ; esc je NO cmp al,3 ; ctrl-C je NO ; invalid char lea dx,BeepMsg call say jmp Again NO: lea dx,NoMsg call say mov ax,4c01h ; exit back to DOS, with 1 errorlevel int 21h YES: lea dx,YesMsg call say mov ax,4c00h ; exit back to DOS, with 0 errorlevel int 21h ;======================================= Say proc near ; on entry DX points to a string to display on screen mov AH,9 int 21h ret Say endp ;======================================= CODE ends end start