'=========================================================================== ' Subject: SET COMMAND$ FROM WITHIN QB Date: 11-27-99 (23:28) ' Author: Keven Coots Code: QB, PDS ' Origin: pitman@midusa.net Packet: DOS.ABC '=========================================================================== DEFINT A-Z '$INCLUDE: 'qb.bi' DECLARE SUB SetCommand (NewCommand$) ' SetCommand [setcmd.bas] ' Written by Keven Coots ' Change COMMAND$ from within Quick Basic ' useful for passing options to CHAINed programs ' http://homepage.netspaceonline.com/~pitman/index.html ' released into the public domain ' works fine in the IDE..... at least on my machine :) ' run QB.EXE with /L CLS PRINT PRINT PRINT PRINT "Original COMMAND$ was - "; COMMAND$ SetCommand "This is a new command tail" PRINT PRINT "New COMMAND$ is - "; COMMAND$ '=================================================================================== '=================================================================================== 'here is an assembly version 'if you want to use it. (does not work in the IDE) and I don't know why yet? 'Compiles fine with MASM 5.1 and TASM 3.1 '; Assemble - MASM SETCMD.ASM; '; Link - LINK /Q SETCMD.OBJ,,,BQLB45.LIB; '; QB /lSETCMD '; Replace BQLB45.LIB with whatever version you are using... '; (ie) BQLB40.LIB for Quick Basic 4.0 ' '<--- start cut here ---> and remove the rem's '.model medium, basic '.code ' ' ' SetCommand proc ' push bp ' mov bp,sp ' push es ' push bx ' mov bx,[bp+6] ;get address of new COMMAND$ ' mov cx,[bx] ;put length in cx ' cmp cl,127 ;COMMAND$ can only be 127 char. max ' jg error ' mov si,[bx+2] ;get offset and store in si ' mov ah,51h ;get PSP ' int 21h ' push bx ; copy PSP Seg into ES ' pop es ' mov di,80h ;Offset of command tail in PSP ' mov al,cl ;length of new command$ in al ' mov ah,20h ;leading space ' stosw ;store in PSP 'nxt: rep movsb ;copy new command$ into PSP ' mov al,0dh ;and add a carriage return ' stosb 'error: pop bx ' pop es ' pop bp ' ret 2 back to basic ' SetCommand endp ' 'END '<--- end cut here ---> SUB SetCommand (NewCommand$) DIM reg AS RegType Tmp$ = NewCommand$ reg.ax = &H5100 ' Get PSP of current proccess INTERRUPT &H21, reg, reg PSPSeg = reg.bx 'segment returend in BX Offset = &H80 'offset in psp of command line DEF SEG = PSPSeg 'set defualt segment to PSP seg Tmp$ = SPACE$(3) + Tmp$ + CHR$(13) 'add leading spaces and trailing carriage return POKE Offset, LEN(Tmp$) 'store length of new command line FOR n = 1 TO LEN(Tmp$) 'now store the new command line in the PSP Offset = Offset + 1 POKE Offset, ASC(MID$(Tmp$, n, 1)) NEXT DEF SEG END SUB