lee@A60.UUCP (Gene Lee) (10/17/86)
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
jkg@gitpyr.gatech.EDU (Jim Greenlee) (10/21/86)
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
klotz@ihuxy.UUCP (Dave Klotzbach) (10/22/86)
> 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.
ron@A60.UUCP (Ron Burns) (10/23/86)
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
timothym@tekigm2.UUCP (Timothy D Margeson) (10/24/86)
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
lee@A60.UUCP (Gene Lee) (10/24/86)
> >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
darmon@polaris.UUCP (Pierre Darmon) (10/27/86)
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
klotz@ihuxy.UUCP (Dave Klotzbach) (10/27/86)
> 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 ...."
timothym@tekigm2.UUCP (Timothy D Margeson) (10/28/86)
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
chaney@ukecc.UUCP (Dan Chaney) (10/29/86)
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 ;-)
jsm@vax1.ccs.cornell.edu (Jon Meltzer) (10/29/86)
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
jsm@vax1.ccs.cornell.edu (Jon Meltzer) (10/29/86)
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