Article View: comp.os.msdos.programmer
Article #6956Re: COMMAND LINE RECALLING
From: David Bingham
Date: Tue, 04 Jun 1991 20:15
Date: Tue, 04 Jun 1991 20:15
59 lines
2537 bytes
2537 bytes
> 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? Next what
> type of interrupt is used to fetch the command? Will I interrupt this
> command to relocate it in a table then continue to execute the command?
> As you can probably tell I'm an inexperianced DOS programmer, but I
> feel this program will help me to learn while not being immpossible
> for my level of abilities. So I would appreciate any suggestions
> and help! By the way I will write this in either C or Assembly.
>
> Thanks in advance!
>
> Roberto Alvarez
> UNIVERSITY OF NORTH DAKOTA
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. Here are two examples:
/* comline.c */
/* demonstrates commandline arguments */
main(argc, argv)
int argc;
char *argv[];
{
int j;
printf("Numer of arguments is %d\n", argc);
for(j=0; j<argc; j++)
printf("Argument number %2d is %s\n", j, argv[j] );
}
------------------------------------------------
/* comline.c */
/* demonstrates commandline arguments */
main(argc, argv)
int argc;
char *argv[];
{
int j;
printf("Numer of arguments is %d\n", argc);
for(j=0; j<argc; j++)
printf("Argument number %2d is %s\n", j, *(argv + j) );
}
Both of these examples work with Turbo C as well as an ANSI compiler such
as Unix cc.
I hope this helps. If you need, I can scare up these routines in assembler.
I know I've got them somewhere. (I'm not exactly partial to doing most of my
programming in assembler :) )
David
************************************************************************
David Bingham * The power of faith and love
Hewlett Packard * Can change the stuff we're made of
bingham@hpnmqa1.sr.hp.com * Michael W. Smith
Technical Details
Message-ID:
<11270008@hpnmdla.sr.hp.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!hplabs!hpl-opus!hpnmdla!binghamReferences:
<91154.184957UD156844@NDSUVM1.BITNET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!hplabs!hpl-opus!hpnmdla!bingham From: bingham@hpnmdla.sr.hp.com (David Bingham) Newsgroups: comp.os.msdos.programmer Subject: Re: COMMAND LINE RECALLING Message-ID: <11270008@hpnmdla.sr.hp.com> Date: 4 Jun 91 20:15:23 GMT References: <91154.184957UD156844@NDSUVM1.BITNET> Organization: HP Network Measurements Div, Santa Rosa, CA Lines: 59