; DOS Errorlevel Code courtesy of Neil Rubenking, PC Magazine
if Param0==0
    Message("Information","DOSERROR.WBT shows how to get an errorlevel back into WinBatch from a DOS application.  Inspect file for more information.")
    exit
endif

;This WBT file works in conjunction with the DOSERROR.BAT file also
;in the sample directory.  Run the DOS program via the DOSERROR.BAT
;file, and the pick the errorlevel out of the result.
;Example


DosProgram="Bananna.com"                         ; Some DOS Program
DosParms="-w -xfred.dat '47 BumbleBee St'"       ; Assorted random parameters

RunWait("DOSERROR.BAT",strcat(DosProgram, " ", DosParms))

a=FileItemize("ERROR*.LVL")
if ItemCount(a," ") !=1 
   Message("Errorlevel Reporting Problem","Multiple ERRORxxxLVL files exist")
   exit
endif

a=ItemExtract(1,a," ")
a=FileRoot(a)
errorlevel=strsub(a,6,strlen(a)-5)

Message("ErrorLevel is",errorlevel)

