'Ä Area: F-QUICKBASIC ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Msg#: 432 Date: 27 Apr 94 10:10:24 ' From: Harry F. Harrison Read: Yes Replied: No ' To: Corey Seliger Mark: ' Subj: Shell? 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' > Ok, Interrupt 21h, 4B00h loads & executes programs, but I ' > don't ' > know how to incorporate it into my program. I would use SHELL, but I ' > want ' > the ERRORLEVEL returned from the child program. What stumps me is the 'EXEC.BAS 'Won't run in the environment, and only links in when linking stand-alone. 'If you are compiling with QB or PDS near strings, then change SSEG/SADD to 'VARSEG/VARPTR. DECLARE FUNCTION Execute% (Program$, Parameter$, DebugFlag%) '$INCLUDE: '..\include\qbx.bi' DECLARE SUB FixShell ALIAS "B$ShellRecover" () DECLARE SUB SetShell ALIAS "B$ShellSetup" () STATIC FUNCTION Execute% (Program$, Parameter$, DebugFlag%) STATIC Regs AS RegTypeX DIM Block AS STRING * 14 'this is the DOS parameter block DIM Parm AS STRING * 63 'and this is the actual parameter text DIM zbuffer$ DIM dummy& DIM exec% DIM file zbuffer$ = Program$ + CHR$(0) 'make an ASCIIZ string for DOS LSET Parm$ = CHR$(LEN(Parameter$)) + Parameter$ + CHR$(13) LSET Block = CHR$(0) + CHR$(0) + MKI$(VARPTR(Parm$)) + MKI$(VARSEG(Parm$)) Regs.AX = &H4B00 'DOS load/execute function Regs.DX = SADD(zbuffer$) 'offset of program name into DX Regs.DS = SSEG(zbuffer$) 'set DS to BASIC's segment Regs.ES = VARSEG(Block) 'segment of parameter block into ES Regs.BX = VARPTR(Block) 'offset of parameter block into BX CALL SetShell '| Unhook interrupts and dummy& = SETMEM(-655360) 'set aside memory for C routines. CALL InterruptX(&H21, Regs, Regs) 'execute it as subordinate process CALL FixShell '| Rehook interrupts and dummy& = SETMEM(655360) '| reclaim far heap. IF Regs.Flags AND 1 THEN 'DOS had an error trying to run exec% = -Regs.AX 'set function value to exit code ELSE Regs.AX = &H4D00 'retrieve subordinate process code CALL InterruptX(&H21, Regs, Regs) exec% = Regs.AX 'set function value to exit code END IF Execute% = exec% END FUNCTION