🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #6996

Re: COMMAND LINE RECALLING

#6996
From: Dave Tutelman
Date: Fri, 07 Jun 1991 11:42
39 lines
2478 bytes
In article <11270008@hpnmdla.sr.hp.com> bingham@hpnmdla.sr.hp.com (David Bingham) writes:
Roberto Alvarez (U. of North Dakota) writes:
>>    I'm interested in writing a program to recall previous parameters
>>    issued on the DOS command line.  My question is where are these
>>    commands placed by DOS.  Are they placed in the PSP?  
>>	... [ and other DOS programming questions ] ...

To which David Bingham (bingham@hpnmdla.sr.hp.com) replies:
>
>  DOS (and Unix) pass two arguments into the program, an integer
>and a pointer to an array of pointers. The integer (argc) represents
>the number of paramaters on the command line. The pointer (argv)
>points to each paramater on the command line....

As in jeopardy -- BZZZT!  
Right answer, but wrong question.
That is, David's reply was factual, but had nothing to do with Roberto's
question.  Roberto wanted to know how MSDOS handled command-line arguments,
not how C programmers could handle them.

The answer is, they occupy the last half of the PSP.  A couple of caveats
(perhaps not all the caveats you need to know) about this string, which
is called the command tail:
   -	It does NOT include the program name itself, just what follows.
   -	It does NOT include any redirection information (>, <, |).
   -	There's no padding, compression, or nulling of "blanks".
   -	Byte 128 is the length of the command tail string.  It's not
	necessarily null-terminated, so you need to know length.
   -	Use it and keep results early, because a very few programs may
	also use these 128 bytes as a disk transfer area (DTA).

This information and the answers to Roberto's other questions are available
in several good books.  My favorite for this level is Norton's "Programmer's
Guide to the IBM PC."  There are other excellent books by Ray Duncan and
by the Waite Group.  I recommend you get a few and keep them at hand as
you program.

Hope this helps.
Dave
Technical Details
Message-ID: <1991Jun7.114217.18409@cbnewsj.att.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uwm.edu!linac!att!cbnewsm!cbnewsk!cbnewsj!davet
References: <91154.184957UD156844@NDSUVM1.BITNET> <11270008@hpnmdla.sr.hp.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uwm.edu!linac!att!cbnewsm!cbnewsk!cbnewsj!davet
From: davet@cbnewsj.att.com (Dave Tutelman)
Newsgroups: comp.os.msdos.programmer
Subject: Re: COMMAND LINE RECALLING
Summary: Yup, the PSP
Message-ID: <1991Jun7.114217.18409@cbnewsj.att.com>
Date: 7 Jun 91 11:42:17 GMT
References: <91154.184957UD156844@NDSUVM1.BITNET> <11270008@hpnmdla.sr.hp.com>
Distribution: na
Organization: AT&T Bell Labs - Lincroft, NJ
Lines: 39