Re: ERRORLEVELS

 BBS: Inland Empire Archive
Date: 07-19-92 (07:44)             Number: 73
From: DICK DENNISON                Refer#: NONE
  To: KEVIN NEWELL                  Recvd: NO  
Subj: Re: ERRORLEVELS                Conf: (2) Quik_Bas
> SM>   Regs.AX = &H4C05   'the 05 is the desired exit code...can be
> changed
> SM>   CALL INTERRUPT(&H21, Regs, Outs)

> Yikes, that's pretty scary.  Take a look at Vol 2 Num 1 of the QBNews
> for a better solution and explanation.

That is a bit too long, but this method will also work - from Brent
Ashley:

'Hold onto your hats, folks, here's a HOT tip!

'I just found out by accident that QB.QLB and QB.LIB, the default
'libraries that come with QuickBASIC support exit with DOS
'ERRORLEVEL!!!

'Here's how you do it:

'start up QB with QB/L QB to use the library.

'declare the SUB as follows:
DECLARE SUB ExitWithErrLvl ALIAS "_exit" (BYVAL ErrorLevel%)
Vare% = 3
'and then use it like:
ExitWithErrLvl Vare%

'Be careful to save your program before you run it in the
'environment, because it actually exits to DOS!  I suspect it's a
'good idea to CLOSE all files before using this call, too.

'I can't believe it's that easy, but it is!!  I've seen gobs of
'messages on the nets about this, and they all had to jump through
'hoops to end up with this result.  What a great find!!



--- VP [DOS] V4.09e
 * Origin: The MailMan  (914)374-3903 NY Quick Share Pt #7 *HST (1:272/34)
Outer Court
Echo Basic Postings

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