BBS: Inland Empire Archive Date: 02-22-93 (23:04) Number: 378 From: WALT MAYO Refer#: NONE To: ALL Recvd: NO Subj: DOS SHELL Conf: (2) Quik_Bas
I don't know who wrote this, but I found it in a snippet file from this echo. It's about 2 years old. Anyone who wants to put a SHELL TO DOS feature in their program will like this one. If DOES require modification if you use the standard QB include file. Get rid of the RegType2 definition and the DECLARE for InteruptX. '===================================================================== 'Sample program to demonstrate DoShell SUBroutine, which uses 'CALL Interrupt from QB.LIB (QB.QLB). '===================================================================== DEFINT A-Z TYPE RegType2 AX AS INTEGER BX AS INTEGER CX AS INTEGER DX AS INTEGER BP AS INTEGER SI AS INTEGER DI AS INTEGER Flags AS INTEGER DS AS INTEGER ES AS INTEGER END TYPE 'You must link with QB.LIB (QB.QLB) to use Interrupt functions DECLARE SUB InterruptX (Intr%, InReg AS RegType2, OutReg AS RegType2) DECLARE SUB DoShell (Before$, Args$, After$) DoShell "Type EXIT to return", "", "Welcome back" 'Just to test it END '===================================================================== 'SUB DoShell(Before$,Args$,After$) 'Purpose: Use this routine rather than 'SHELL' and the original ' drive & directory will be restored when 'EXIT'ing the shell. ' Before$ = A reminder message to the user. Usually it will be ' something like "Type EXIT to return" ' After$ = A string message to the user upon reentry into the ' calling program. ' Args$ = Will be the null string "" for a plain vanilla SHELL. ' The SUB calls 'SHELL' as 'SHELL Args$' '====================================================================== SUB DoShell (Before$, Args$, After$) 'Declare some stuff to use DIM InReg AS RegType2 DIM OutReg AS RegType2 DIM CurrentDrive AS INTEGER DIM CurrentDir AS STRING * 64 'Get current disk drive InReg.AX = &H19 * 256 InterruptX &H21, InReg, OutReg CurrentDrive = OutReg.AX MOD 256 'Get current directory InReg.AX = &H47 * 256 InReg.DX = CurrentDrive + 1 'Note adding one to drive for this, or 'could use 0 for default drive InReg.DS = VARSEG(CurrentDir) InReg.SI = VARPTR(CurrentDir) InterruptX &H21, InReg, OutReg 'Do the shell IF Before$ <> "" THEN CLS : PRINT Before$ 'Optional SHELL Args$ IF After$ <> "" THEN CLS : PRINT After$ 'Optional 'Change to old disk drive InReg.AX = &HE * 256 InReg.DX = CurrentDrive InterruptX &H21, InReg, OutReg '(InReg.AX MOD 256 is the # of logical drives in the 'system if anyone is interested) 'Change to old subdirectory (Could use Int &H21 func &H3B instead) ToDir$ = CHR$(ASC("A") + CurrentDrive) + ":\" + LEFT$(CurrentDir, INSTR(CurrentDir, CHR$(0))) CHDIR ToDir$ END SUB -----------------------> \\/alt --- GoldED 2.40 * Origin: Periscope! Home of the OPTOMETRY Echo! (1:3627/101)
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