home *** CD-ROM | disk | FTP | other *** search
- '******************************EXIT2.BAS*********************************
- '
- '
- 'JRD NOTE: Thu 04-07-1994 11:25:48
- '
- 'Tony Elliot just wrote a piece in Visual BASIC Programmer's Journal saying
- 'that what I did not only DOESN'T WORK, but it locks the computer.
- 'So, I am trying the method he mentioned.
- '
- 'Dave Cleary wrote about the same code back in about 1991, it is to use
- 'a BASIC -internal- run time library command with the ALIAS command as
- 'follows:
- '
- 'DECLARE SUB EndLevel ALIAS "_exit" (BYVAL ErrorLevel%)
- '
- 'See ALIAS.BAS which contains the note about this. At the time, I
- 'didn't understand it. Since you are calling an -internal- command,
- 'there is no SUB to flesh out, guess that's what confused me.
- '
- 'By the way, the original works fine..... so far, but in fairness to
- 'everyone, once I heard from the guys that use debuggers like Periscope
- 'that what I did maybe unstable, had to also give you what they say is a
- 'better method.
- '
- 'EXIT2.BAS works with BATCH2.BAT, and must be compiled to a stand-alone
- '*.EXE file,
- '
- ' ***** DO NOT RUN IT IN THE QB.EXE ENVIRONMENT!!! ******
- '
- '------------------SOME TEXT OF EXITCODE.BAS FOLLOWS------------------
- '
- '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.
- '
- 'JRD NOTE:
- 'With this code you can set an ERRORLEVEL when you exit your QuickBASIC
- '4.5 program.
- '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. '1/19/94
- '
- '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 the cursor need nothing more
- 'than the following to prevent the cursor from disappearing:
- '
- 'LOCATE , , 1 ,4 ,7
- '
- 'declarations, etc.
- DEFINT A-Z
- DECLARE SUB LocateIt (row%, text$)
- DECLARE SUB ColorIt (Fgd%, Bgd%)
- DECLARE SUB EndLevel ALIAS "_exit" (BYVAL ErrorLevel%)
-
- 'executable code
- 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
-
- CALL EndLevel(ExitCode%)
- 'the next never gets printed as we are out of here
- text$ = "Return Code is: " + STR$(Regs.ax MOD 256)
-
- SUB ColorIt (Fgd, Bgd)
- COLOR Fgd, Bgd
- END SUB
-
- SUB LocateIt (row%, text$)
- LOCATE row%, 41 - (LEN(text$) \ 2)
- PRINT text$;
- END SUB
-
-