Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!dayton!ems!A60!lee From: lee@A60.UUCP (Gene Lee) Newsgroups: net.micro.pc Subject: Re: Turbo Pascal and arguments Message-ID: <633@A60.UUCP> Date: Mon, 27-Oct-86 07:35:45 EST Article-I.D.: A60.633 Posted: Mon Oct 27 07:35:45 1986 Date-Received: Tue, 28-Oct-86 06:41:32 EST References: <623@A60.UUCP> <2444@gitpyr.gatech.EDU> <1628@ncoast.UUCP> Reply-To: lee@A60.UUCP (Gene Lee) Organization: Sperry Corp. - Roseville, MN Lines: 49 In article <1628@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes: >Quoted from <2444@gitpyr.gatech.EDU> ["Re: Argv[0] in TURBO PASCAL"], by jkg@gitpyr.gatech.EDU (Jim Greenlee)... >+--------------- >| In article <623@A60.UUCP> lee@A60.UUCP (Gene Lee) writes: >| > Can anyone tell me how to get the Program name ( the name the >| > program was called by ) from Turbo Pascal? Lattice C does it so >| > I know it can be found. I just don't know where in memory MS-DOS >| > keeps it. Thanks in advance >| >| Turbo Pascal does not support equivalent procedures to the argv() >| and argc() functions found in most C (and in some Pascal) libraries. >| To get at the command line from within Turbo, you have to address >| the memory location(s) where the command line is stored. The following >| (from Borland's "Turbo Tutor" book) will access arguments passed to >| a program: >+--------------- > >Turbo Pascal 3.0 has the functions: > >function ParamCount : integer; >function ParamStr(argc : integer) : string[255]; > >The manual doesn't say whether ParamStr(0) is valid or not. > Since the time I first asked this question I have dug out the answer. If INTERESTED then keep reading else type n When a program is loaded into memory the PSP is setup at offset 0. At offset $2C of the PSP, the environment strings address is found. The last entry of of the environment string is the loadpath and the program name. Using debug you can verify this Debug myprogram.com { or myprogram.exe } d $2c d $????:0 { address comes from last display } d { as many times as needed to get to the end of the environment string } -- Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee Sperry Corporation ATT: (612) 635-6334