Re: Command Line Switches

 BBS: Inland Empire Archive
Date: 11-10-92 (10:12)             Number: 378
From: DICK DENNISON                Refer#: NONE
  To: MATT ROBERTS                  Recvd: NO  
Subj: Re: Command Line Switches      Conf: (2) Quik_Bas
MR> Really?  I didn't know that (obviously :-).  What if you want your com
MR> arguments to be case sensitive?  Can you still use LCASE$ or is that
MR> cancelled by COMMAND$?

'Try this:

'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
'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.

' $INCLUDE: ''

PRINT "Here's the original command line:"
PRINT "["; 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.
  ' = &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))
  ' restore BASIC data segment and return data
  CmdLine$ = CmdBuild$

--- VP [DOS] V4.09e
 * Origin: The MailMan  (914)374-3903 NY Quick Share Pt #7 *HST (1:272/34)
Outer Court
Echo Basic Postings

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