Thread View: net.micro.pc
14 messages
14 total messages
Started by Gene Lee
Fri, 17 Oct 1986 15:15
Argv[0] in TURBO PASCAL
Author: Gene Lee
Date: Fri, 17 Oct 1986 15:15
Date: Fri, 17 Oct 1986 15:15
10 lines
839 bytes
839 bytes
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
--
Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee
Sperry Corporation ATT: (612) 635-6334
Re: Argv[0] in TURBO PASCAL
Author: Jim Greenlee
Date: Tue, 21 Oct 1986 02:05
Date: Tue, 21 Oct 1986 02:05
53 lines
2448 bytes
2448 bytes
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
>
>
>--
>Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee
>Sperry Corporation ATT: (612) 635-6334
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:
============================ cut here ================================
program CommandLine;
{ This program demonstrates how to get information off the command
line. One thing you must remember-32 characters are always
there for you to use-if you want to use the full 127, the first
statement in your program must parse the command line and retrieve
the information as any subsequent reads or writes will shorten the
command line to 32 characters. }
type
CommandString = string [127];
var
Buffer : CommandString;
CL : CommandString absolute cseg:$80;
begin
Buffer := CL;
Gotoxy(20,12);
Writeln('|',Buffer,'|');
end. { of program CommandLine }
============================== cut here =============================
The book mentions that this is only good for getting arguments above
arg(0), which doesn't really solve your specific problem, but I hope
it is of some general use.
Jim Greenlee
--
The Shadow
Georgia Insitute of Technology, Atlanta Georgia, 30332
...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!jkg
Re: Argv[0] in TURBO PASCAL
Author: Dave Klotzbach
Date: Wed, 22 Oct 1986 15:47
Date: Wed, 22 Oct 1986 15:47
19 lines
1534 bytes
1534 bytes
> Turbo Pascal does not support equivalent procedures to the argv() > and argc() functions found in most C (and in some Pascal) libraries. > This is not true. Earlier version of TURBO did not have this facility, but with TURBO version 3.0 and later have supported these through the function argcnt and the array argstr[].. Argcnt is the number of arguments on the command line and argstr is the equiv. of *argv[]. Since I do not have my handbook with me I may have the names of the function and array wrong but I have used both off these in my development. > The book mentions that this is only good for getting arguments above > arg(0), which doesn't really solve your specific problem, but I hope > it is of some general use.` The problem with arg(0) is an MSDOS problem. None of the language processors for MSDOS can supply you with tthe name your program was invokked with. This is a limimitation in the way the PSP is constructed. This information, of course, is based on MSDOS 2.1.
Re: Argv[0] in TURBO PASCAL
Author: Ron Burns
Date: Thu, 23 Oct 1986 13:28
Date: Thu, 23 Oct 1986 13:28
41 lines
1814 bytes
1814 bytes
In article <2444@gitpyr.gatech.EDU> jkg@gitpyr.UUCP (Jim Greenlee) writes:
>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
>>Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee
>>Sperry Corporation ATT: (612) 635-6334
>
>Turbo Pascal does not support equivalent procedures to the argv()
>and argc() functions found in most C (and in some Pascal) libraries.
What Mr. Greenlee must have meant was:
The revision of Turbo Pascal I have does not support.....etc.
In fact, TP version 3.0 provides two functions of interest to this discussion.
1. number_of_space_delimited_parameters := ParamCount;
and
2. parameter_string := paramStr(which_parameter_would_you_like); {1,2,3..}
for a command line like :
C>progname 1 two 3
paramcount returns --->3
paramstr(1) --->1 (ascii char)
paramstr(2) --->two (ascii chars)
etc.
Now, How do you get the equivalent of paramstr(0), or the filename of the
program???
Ron
--
Ron Burns
UUCP: ...caip|meccts|dicome|umn-cs!ncs-med!sx7000!A60!ron
Re: Argv[0] in TURBO PASCAL
Author: Timothy D Margeson
Date: Fri, 24 Oct 1986 03:17
Date: Fri, 24 Oct 1986 03:17
31 lines
1657 bytes
1657 bytes
Hi,
About Turbo Pascal command lines.... YOU CAN GET AT THEM EASILY IN 3.01A.
The function is PARAMCOUNT and PARAMSTR().
PARAMCOUNT returns the number of arguments, PARAMSTR() with an integer index
returns the passed parameter. You can even pass dummy variables when compiling
to memory by using the P option from the option menu.
ANYBODY ELSE IS WRONG!
I don't know right off if PARAMSTR(0) works, I've never had occasion to use it.
I have used PARAMSTR(X) where X>0 and X<10 and it works fine.
You can find more info (not much though) from the Turbo Pascal Reference Manual
page 144, top two entries.
The entries returned are direct copies of the PMC-DOS command line buffer, so I
presume (something about an ass out of you and an ass out of me) that the (0)
index will return the called command.
By, good luck....
--
Tim Margeson (206)253-5240
PO Box 3500 d/s C1-937 @@ 'Who said that?'
Vancouver, WA. 98668
{allegra..inhp4..decvax..ucbvax}!tektronix!tekigm2!timothym
Re: Argv[0] in TURBO PASCAL
Author: Gene Lee
Date: Fri, 24 Oct 1986 12:39
Date: Fri, 24 Oct 1986 12:39
19 lines
1506 bytes
1506 bytes
>
>The problem with arg(0) is an MSDOS problem. None of the language processors
>for MSDOS can supply you with tthe name your program was invokked with. This
>is a limimitation in the way the PSP is constructed. This information, of
>course, is based on MSDOS 2.1.
DON'T say none, Lattice C on the PC gives argv[0] as the program name
and complete path it was executed under. This is what inspired me to
ask the question about a TP inplemention in the first place.
Since then I have found that the the program's name can be found at
$0:143d on my PC running DOS 3.? but on other machines its at a slightly
different address. I assume this data is part of a table but I don't know
were or how to find the starting address of this table. If anyone has a
handle on what I'm talking about, I would greatly appreciate your help.
--
Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee
Sperry Corporation ATT: (612) 635-6334
Turbo Pascal and arguments
Author: Brandon Allbery
Date: Fri, 24 Oct 1986 23:30
Date: Fri, 24 Oct 1986 23:30
32 lines
2114 bytes
2114 bytes
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
Re: Argv[0] in TURBO PASCAL
Author: Pierre Darmon
Date: Mon, 27 Oct 1986 00:05
Date: Mon, 27 Oct 1986 00:05
23 lines
1684 bytes
1684 bytes
In article <1134@tekigm2.UUCP> timothym@tekigm2.UUCP (Timothy D Margeson) writes: >About Turbo Pascal command lines.... YOU CAN GET AT THEM EASILY IN 3.01A. > > >The function is PARAMCOUNT and PARAMSTR(). > >PARAMCOUNT returns the number of arguments, PARAMSTR() with an integer index >returns the passed parameter. You can even pass dummy variables when compiling >to memory by using the P option from the option menu. > >I don't know right off if PARAMSTR(0) works, I've never had occasion to use it. >I have used PARAMSTR(X) where X>0 and X<10 and it works fine. > I just tried it with Turbo 3.01A on an PC AT DOS 3.1. ParamStr(0) returns an empty string. Too bad. However I tried up to 40 arguments and used Paramstr(40) and got them all. So I believe it's safe to assume that you can go up to whatever is needed, limited by the 127 char size of the command line -- Pierre Darmon, IBM Thomas J. Watson Research Center. .....seismo!philabs!polaris!darmon. darmon.yktvmz.ibm@csnet-relay
Re: Turbo Pascal and arguments
Author: Gene Lee
Date: Mon, 27 Oct 1986 12:35
Date: Mon, 27 Oct 1986 12:35
49 lines
2414 bytes
2414 bytes
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
Re: Argv[0] in TURBO PASCAL
Author: Dave Klotzbach
Date: Mon, 27 Oct 1986 15:08
Date: Mon, 27 Oct 1986 15:08
12 lines
1106 bytes
1106 bytes
> DON'T say none, Lattice C on the PC gives argv[0] as the program name
> Gene Lee UUCP: ...ihnp4!{meccts,dayton,rosevax}!ems!A60!lee
> Sperry Corporation ATT: (612) 635-6334
*** REPLACE THIS LINE WITH YOUR MESSAGE ***
Lattice C cheated and put the name of the compiled program with main() in
it in a location that would then be used to replace argv[0]. It did not get
the information from MSDOS. This is clearly stated in the manual, See
section 4.1.4 under the description for args:
"A dummy argv[0] is therefore supplied ...."
Re: Argv[0] in TURBO PASCAL
Author: Timothy D Margeson
Date: Mon, 27 Oct 1986 23:18
Date: Mon, 27 Oct 1986 23:18
21 lines
1300 bytes
1300 bytes
In article <627@A60.UUCP> ron@A60.UUCP (Ron Burns) writes:
>
>Now, How do you get the equivalent of paramstr(0), or the filename of the
>program???
>
One way may be to read the command line variable directly, it resides at
CS:0 to CS:100. I have seen the program call name there when running DEBUG,
and think that you can count on the program name always being there.
I think the actual offset is 80H, but am not sure.
TP, the best thing in a bathroom.
--
Tim Margeson (206)253-5240
PO Box 3500 d/s C1-937 @@ 'Who said that?'
Vancouver, WA. 98668
{allegra..inhp4..decvax..ucbvax}!tektronix!tekigm2!timothym
Re: Argv[0] in TURBO PASCAL
Author: Dan Chaney
Date: Wed, 29 Oct 1986 02:15
Date: Wed, 29 Oct 1986 02:15
19 lines
1262 bytes
1262 bytes
I am looking over various alternatives for linking 4-8 terminals to an
AT and maintaining adequate disk storage. One method appears to be a
combination of Bernoulli boxes (20/20) and any of the several 9 track
tape drives available. (We will most likely LanLink the terms)
My question is - has anyone had extensive difficulties with any of the
systems above listed, specifically compatibility problems?
--- Also, anyone with some old Televideos for sale or remarks on current
9 track 1600/6250 BPI 1/2" Tape systems, please feel free to respond
Thank you. (EOD)
Dan
P.S. Eod := End of Disclaimer ;-)
Re: Argv[0] in TURBO PASCAL
Author: Jon Meltzer
Date: Wed, 29 Oct 1986 17:43
Date: Wed, 29 Oct 1986 17:43
22 lines
1392 bytes
1392 bytes
In article <1637@ihuxy.UUCP> klotz@ihuxy.UUCP (Dave Klotzbach) writes: >> Turbo Pascal does not support equivalent procedures to the argv() >> and argc() functions found in most C (and in some Pascal) libraries. >> >This is not true. Earlier version of TURBO did not have this facility, >but with TURBO version 3.0 and later have supported these through the >function argcnt and the array argstr[].. Argcnt is the number of arguments >on the command line and argstr is the equiv. of *argv[]. > >Since I do not have my handbook with me I may have the names of the function >and array wrong but I have used both off these in my development. > The correct names are ParamCnt and ParamStr. ParamStr is a function, not an array. (For example, ParamStr(1) is the first parameter). -- Jon Meltzer
Re: Argv[0] in TURBO PASCAL
Author: Jon Meltzer
Date: Wed, 29 Oct 1986 17:51
Date: Wed, 29 Oct 1986 17:51
13 lines
867 bytes
867 bytes
In article <202@vax1.ccs.cornell.edu> jsm@vax1.UUCP (Jon Meltzer) writes: >The correct names are ParamCnt and ParamStr. ParamStr is a function, not an >array. (For example, ParamStr(1) is the first parameter). > Sorry ... ParamCount. -- Jon Meltzer
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads