home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_BAS
/
EXITCODE.ZIP
/
EXITCODE.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-01-19
|
3KB
|
105 lines
'***************************EXITCODE.BAS*********************************
'JRD NOTE:
'With this code you can set an ERRORLEVEL when you exit your QuickBASIC
'4.5 program.
'
'I've been looking for this technique to use in QuickBASIC 4.5 for
'years.... but it was there all the time by using CALL interrupt.
'I know you can do this with PDS 7.1 and VisualBASIC for DOS, with
'
'END Exitcode% Statement
' but....
'
'I wanted to know -where- the COMMAND.COM got that ERRORLEVEL number from
'Now I know...
'
'&H21 Interrupt, Service 4CH is the "Terminate with return code"
'We try it to exit and set an ERRORLEVEL.
'
'WOW! if you run this in the QuickBASIC Environment....
'
' All HELL breaks loose!
'
'So....DON'T DO IT.... Remember you were warned. This overwrites ROM,
'some how messes up LPT1, and does other weird things.... INCLUDING
'causing the cursor to disappear if you run the executable code,
'EXITCODE.EXE from a batch file and don't set the cursor as this program
'does.
'
'BUT.... the good news is.... IT WORKS.
'
'I made BATCH.BAT to be used with this. It is a true blue
'IF ERRORLEVEL batch file
'need to make SURE you slap some code for the cursor. Need nothing more
'than the following to prevent the cursor from disappearing:
'
'LOCATE , , 1 ,4 ,7
'
'John De Palma on CompuServe 76076,571
'1/19/94
'
'=============================END OF TEXT=============================
'
'declarations, etc.
DEFINT A-Z
TYPE RegType
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
ds AS INTEGER
es AS INTEGER
END TYPE
DECLARE SUB INTERRUPT (IntNum AS INTEGER, InRegs AS RegType, OutRegs AS RegType)
DECLARE SUB LocateIt (row%, text$)
DECLARE SUB ColorIt (Fgd%, Bgd%)
'executable code comes next
COLOR 15, 1
CLS
text$ = "TYPE: an Exit Code (1 to 10) to test"
CALL LocateIt(10, text$)
text$ = SPACE$(2)
CALL ColorIt(11, 0)
CALL LocateIt(11, text$)
row = CSRLIN
col = POS(0)
LOCATE row, col - 2, 1, 4, 7
INPUT "", ExitCode%
CALL ColorIt(15, 1)
text$ = "Setting ERRORLEVEL TO: " + STR$(ExitCode%)
CALL LocateIt(13, text$)
PRINT
DIM Regs AS RegType
Regs.ax = &H4C00 + ExitCode% 'AH = 4C; AL = ExitCode%
' ┌───────────────────────────────────────┐
' │ * * * * D A N G E R * * * * │
' └───────────────────────────────────────┘
' DO =NOT= run the CALL INTERRUPT in the QuickBASIC environment!!!!!!
CALL INTERRUPT(&H21, Regs, Regs)
'the next never gets printed as we are out of here
text$ = "Return Code is: " + STR$(Regs.ax MOD 256)
CALL LocateIt(15, text$)
SUB ColorIt (Fgd, Bgd)
COLOR Fgd, Bgd
END SUB
SUB LocateIt (row%, text$)
LOCATE row%, 41 - (LEN(text$) \ 2)
PRINT text$;
END SUB