Board index » delphi » Passing Parameters in Pascal

Passing Parameters in Pascal

Can anyone tell me how to pass a parameter from the command line into a
Turbo Pascal 7.0 program. I have a filter program I wrote that would be much
improved if I could pass a couple of parameters into from the command
prompt. What library and procedure should I use?

Thanks in advance,{*word*106} Lewis
 rle...@pe.net

 

Re:Passing Parameters in Pascal


JRS:  In article <69uo4i$ne...@nntp.pe.net> of Sun, 18 Jan 1998 21:25:35
in comp.lang.pascal.borland,{*word*106} Lewis <rle...@pe.net> wrote:

Quote
>Can anyone tell me how to pass a parameter from the command line into a
>Turbo Pascal 7.0 program. I have a filter program I wrote that would be much
>improved if I could pass a couple of parameters into from the command
>prompt. What library and procedure should I use?

To you and to numerous others - please learn how to cross-post one
message to more than one group, rather than wastefully duplicating.
Then each response should appear in each group, rather than in different
threads.    Web <URL: http://www.merlyn.demon.co.uk/news-use.htm#XP>

Try the on-line help for ParamStr, ParamCount; and Web
        <URL: http://www.merlyn.demon.co.uk/pas-norm.htm#CLPars>

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

Re:Passing Parameters in Pascal


Quote
"dick Lewis" <rle...@pe.net> wrote:
>Can anyone tell me how to pass a parameter from the command line into a
>Turbo Pascal 7.0 program. I have a filter program I wrote that would be much
>improved if I could pass a couple of parameters into from the command
>prompt. What library and procedure should I use?
>Thanks in advance,{*word*106} Lewis
> rle...@pe.net

In TP 6.0 it is in the HELP under ParamStr and ParamCt. Not sure about
7.0 but maybe it is something similarly spelled.

Re:Passing Parameters in Pascal


Someone asked:

Quote
>>How do you pass parameters?
>In TP 6.0 it is in the HELP under ParamStr and
>ParamCt. Not sure about 7.0 but maybe it is
>something similarly spelled.

In TP 7.0 searching the help index under ParamStr gives the following,
and ParamCount will return the total number of command-line parms.

  ParamStr (function)
  ===================
 Returns a specified command-line parameter.

  Declaration:
  function ParamStr(Index): String;

  Target:
  Windows, Real, Protected

  Remarks:
  Index is an expression of type Word. ParamStr
  returns the Indexth parameter from the command
  line, or an empty string if Index is greater than
  ParamCount. ParamStr(0) returns the path and file
  name of the executing program (for example,
  C:\BP\MYPROG.EXE).

  See Also:
  ParamCount

  Sample Code:

{Parstrng.PAS}

{Sample code for the Paramstr function.}

var I: Word;
begin
 for I := 1 to ParamCount do
   Writeln(ParamStr(I));
end.

Re:Passing Parameters in Pascal


Quote
> Can anyone tell me how to pass a parameter from the command line into a
> Turbo Pascal 7.0 program. I have a filter program I wrote that would be much
> improved if I could pass a couple of parameters into from the command
> prompt. What procedure should I use?

   ParamCount and ParamStr(n)

Re:Passing Parameters in Pascal


ParamStr( 1..n ); returns the x-th parameter
and if the argument is 0 it'll return the command line

Moraliyski

Quote
dick Lewis wrote:
> Can anyone tell me how to pass a parameter from the command line into a
> Turbo Pascal 7.0 program. I have a filter program I wrote that would be much
> improved if I could pass a couple of parameters into from the command
> prompt. What library and procedure should I use?

> Thanks in advance,{*word*106} Lewis
>  rle...@pe.net

Re:Passing Parameters in Pascal


In article <34C31E7A.4A156...@ibm.net>,
Peter Moraliyski  <huibm...@ibm.net> wrote:

Quote
>ParamStr( 1..n ); returns the x-th parameter
>and if the argument is 0 it'll return the command line

No, with 0 it returns the path to the program. (On Dos 3+)

Osmo

Re:Passing Parameters in Pascal


On Mon, 19 Jan 1998 21:24:14 GMT, clifp...@airmail.net (Clif Penn)
wrote:

Quote
>In TP 6.0 it is in the HELP under ParamStr and ParamCt. Not sure about
>7.0 but maybe it is something similarly spelled.

It is ParamCount, not ParamCt. And it's the same it TP/BP7.

Regards, Tom..
--
Tom Wellige
Get my e-mail address from <http://www.kst.dit.ie/people/twellige>
Join the fight against spam: <http://www.cauce.org>

Other Threads