BBS: Inland Empire Archive Date: 11-23-92 (14:49) Number: 349 From: JOHN GALLAS Refer#: NONE To: MIKE KERR Recvd: NO Subj: Compiler Conundrums! Conf: (2) Quik_Bas
MK>The problem I'm having now, is similar, yet not. Sorry, I won't be MK>cryptic any more! :-) I have just written a program that will print MK>C:\QBASIC\PP.BAS MK>Which is EXACTLY what I want. I get this from MID$(COMMAND$,4). So, MK>what's the problem? When I compile the program, all that gets read in MK>is: MK>QBASIC\PP.BAS <etc etc> Heres a routine that'll use interrupts to read in the command line entered from DOS. It shouldn't take off any characters, and it even preserves upper/lower case. '================================================================= 'Date: 04-11-91 'From: BRENT ASHLEY 'Subj: ORIGINAL COMMAND LINE; preserving lower case 'Conf: QBASIC (62) 'The command line as entered at the DOS prompt, in all its mixed-case 'splendour, is found at offset &H81 of the program's PSP (Program Segment 'Prefix), with the length of the command string at offset &H80 of the 'PSP. ' 'Finding your PSP from within QuickBASIC entails Interrupt calls. ' ~~~~~~~~~ 'That same area of the PSP, however, is also the default disk transfer 'area for the program (or is it the default File Control Block? - I don't 'have my references handy) At any rate, I suspect QB always defines its 'own DTAs and FCBs, so the data won't be overwritten, but this cannot 'always be guaranteed. It would be best, therefore, if you were to get 'this info, to get it as early in the program's execution as possible, 'especially before any file I/O. '====================================================================== DECLARE FUNCTION CmdLine$ () DEFINT A-Z ' $INCLUDE: 'qb.bi' PRINT "Here's the original command line:" PRINT "["; CmdLine$; "]" END FUNCTION CmdLine$ ' ' CmdLine - returns original command line ' DIM Regs AS RegType STATIC CmdLen, CmdBuild$, i ' ' DOS Interrupt 21h service 62h returns the segment ' address of the running program's PSP in the bx register. ' Regs.ax = &H6200 CALL Interrupt(&H21, Regs, Regs) DEF SEG = Regs.BX ' ' The command line's length is found at offset 80h of the PSP ' and the actual command line starts at 81h ' CmdBuild$ = "" CmdLen = PEEK(&H80) FOR i = 1 TO CmdLen CmdBuild$ = CmdBuild$ + CHR$(PEEK(&H80 + i)) NEXT ' ' restore BASIC data segment and return data ' DEF SEG CmdLine$ = CmdBuild$ END FUNCTION The only problem is, you can't change the command line from within the QB environment, but if you're always running from an exe, it'll work fine. * OLX 2.1 TD * I don't have a life, I have a BBS.. --- RyPacker v2.5b * Origin: The Ghost Mode - An RyBBS System! (612)-688-0026 (1:282/3006)
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