Hello Sander
On Tuesday, 2 July 1996 13:51:10, you wrote to All:
SS> Could someone hand me some code to read the returned
SS> errorlevel from a program? Like, I shell to SCAN, and it returns
SS> ErrorLevel 3, how do I 'read' this in Basic??
Here it the code you need:
/*
'Pbexec.bas returns an errorlevel from a shelled program with DOS EXEC
Function
'Written By Ethan Winer for Microsoft Basics
'Converted to Power basic 3.0 by Gary Blydenburgh
'Errorlevel = PBEXEC(Program$,Parameter$)
FUNCTION PBEXEC (Program$,par$) STATIC
dim block as string * 14
dim parm as string * 50
zbuffer$=program$+chr$(0)
lset parm$ = chr$(len(par$))+par$+chr$(13)
lset block$ = chr$(0)+chr$(0)+mki$(varptr(parm$))+MKI$(varseg(parm$))
dummy&=setmem(-500000)
reg 1, &H4B00
reg 9,varseg(block$)
reg 4, strptr(zbuffer$)
reg 8, strseg(zbuffer$)
reg 2,varptr(block$)
call interrupt &H21
if reg(0) and 1 then
pbexec=255 'Errorlevel is 255 for and DOS Error
select case reg (1)
case 1,2,3,5,8,10,11
dummy&=setmem(500000)
exit function
end select
end if
reg 1, &H4D00
call interrupt &H21
pbexec=reg(1)
dummy&=setmem(500000)
END FUNCTION
*/
Friendly greeting you,
Hans Lunsing, Fido : 2:281/607.214, 2:282/610.12
Internet : jlunsing@doge.nl
--- Terminate 4.00/Pro
# Origin: BBS De Lauwers For BASIC Programmers! ++3159468840
(119:3102/101.12)
---------------
* Origin: United Bbs Systems Europe MailGate to -> Fido USA (2:2802/337.0)
|