[net.micro.pc] Turbo Pascal and arguments

allbery@ncoast.UUCP (Brandon Allbery) (10/25/86)

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.

++Brandon
-- 
  ---------------- /--/	Brandon S. Allbery		UUCP: decvax!cwruecmp!
 /              / /|\/	Tridelta Industries, Inc.        ncoast!tdi2!brandon
----    -------- /-++	7350 Corporate Blvd.		PHONE: +1 216 974 9210
   /   / /---,  ----	Mentor, Ohio 44060		SYSOP: UNaXcess/ncoast
  /   / /    / /  /	     -- HOME --			 (216) 781-6201 24 hrs.
 /   / /    / /  /	6615 Center St. Apt. A1-105	ARPA:  ncoast!allbery%
----  -----~ ----	Mentor, Ohio 44060-4101		case.CSNET@relay.cs.net

lee@A60.UUCP (Gene Lee) (10/27/86)

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