TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: GARY MAJOR
from: ERIC SCHONNING
date: 1995-05-30 00:00:00
subject: Re: Errorlevels

GM> I am looking for a way to trap an errorlevel from a shell command. whe
GM> Irun pkzip in a shell and i want to trap the errorlevel returned by
GM> pkzip and use it in another part of my program. How could i do this?
  
I have found the only way to return an errorlevel back into PB is to
execute the .exe or .com file in a batch file.  If you execute the .exe
or .com directly it will not return the errorlevel.  So just make up a
batch file with the executable filename in it (I usually make it on the
fly) and shell that.  EX:
 
open "batchfil.bat" for output as #1
print #1,"filename.exe param1 param2"
close #1
shell "batchfil.bat"
'now get errorlevel
reg 1,&4d00
call interrupt &h21
ret.error=reg(1) mod 256
 
For the 2nd part of your question, where to get info on DOS interrupts
& registers, you need a good book on it.  I've always used "Using
Assembly Language" by Allan Wyatt, now on ver 3 last I saw.  There are
plenty of other good books, as well as a free listing on the PB BBS.
You'll notice in those that they make reference to AH and AL, BH & BL,
etc. and PB only has AX, BX, etc.  For example, the interrupt to get
the child process errorlevel is INT 21h, function 4Dh where AH=4Dh.  To
get AX from AH & AL just multiply your AH value by 256 (or 100h) and
then add the AL value.  To get AH from AX divide by 256, to get AL from
AX use the MOD function (like in example above).  Once you get the
book or listings look up the int 21 function 4d, then look at the above
code and hopefully you can see the logic behind it.  Its pretty easy to
do.  And with the addition of the BIT and BITS statements in new PB
checking flags and various other goodies is a cinch to do.  If you have
other questions this is the place to ask them.
 
Eric
 
ps: the echo is a bit slow, I get around the same # of messages per
week also.  Some daze get none, others a bunch.
--- QM v1.00
---------------
* Origin: Creekside Manor (805) 484-8016 CdCom Support BBS (1:206/2512.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.