BBS: Inland Empire Archive Date: 01-31-93 (15:14) Number: 375 From: ROB MCKEE Refer#: NONE To: ANNE BUSSELL Recvd: NO Subj: Exiting with a DOS Errorl Conf: (2) Quik_Bas
Hello Anne!
You wrote in a message to All:
AB> Is there anyway to force a QuickBASIC program to exit on a
AB> particular DOS errorlevel???
Here a trick that I use:
CLOSE
StuffKeyBuff "ErrorSav" + CHR$(13) ' I'll let you
figure that out.. <G> OPEN "ErLvSav.dat" FOR OUTPUT AS
1: CLOSE
KILL "ErLvSav.DAT"
OPEN "ErLvSav.DAT" FOR BINARY AS 1
A$= RIGHT$("000"+LTRIM$(STR$(EXITCODE%)),3)
A$= A$+CHR$(13)+CHR$(10)+chr$(26)+CHR$(EXITCODE%)
PUT #1,,A$
END
'Then ErrorSav.com get's run and read's the ErlvSav.dat
and issues the ' Errorlevel stored in it, then it kills
the ErLvSav.Dat
Here's the Hex for ErrorSav.COM
The Asm prog is after the Hex and is writen for A86 assembler Length
AB
E94D0045724C765361762E6461740000000000000D0A2400546869732050
26F
6772616D204861732070726F626C656D730D0A2445524C565341562E4441
420
776173204E6F7420466F756E640D0A241E1EE91C00BA3401E80C00E90E00
A18
01E80300E90500B409CD21C3B8004CCD210E1FBA030133C9B8003DCD2172
6A3
0F0193B90700BA1101B43FCD21C606160124B43ECD21BA0301B80041CD21
A11 01E8C3FFA01701B44CCD21
ORG 0100
jmp main
ErLvSav DB 'ErLvSav.dat', 0
FileHandle DW 0
out_100 DB 0
out_10 DB 0
out_1 DB 0
out_str DB 0D,0A
EndOfStr DB 024
ErrorLevel DB 00
OopsMsg DB 'This Program Has
problems',0d,0a,024 FileNotFnd DB 'ERLVSAV.DAT was
Not Found',0d,0a,024 NotFnd:
mov dx,offset FileNotFnd
call outStr
jmp exit0
Oops:
mov dx,offset OopsMsg
call outStr
jmp exit0
outstr:
mov ah,9
int 021
ret
Exit0:
mov ax,04c00
int 021
main:
mov dx, offset ErLvSav
xor cx,cx
mov ax,03d00
int 021
jc NotFnd
mov FileHandle,ax
xchg bx,ax
mov cx,07
mov dx,offset Out_100
mov ah,03f
int 021
mov EndOfStr, 024
mov ah,03e
int 021
mov dx, offset ErLvSav
mov ax,04100
int 021
MOV DX,Offset Out_100
Call OutStr
MOV AL,ErrorLevel
MOV AH,04c
INT 021
Catcha Later , I'll see you on the flip side - Rob
--- timEd/B6
* Origin: Flyer_Proof_Computer_Svs,V32B,V42B,XA (1:125/1212.13)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET