Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ParamCount

36 views
Skip to first unread message

Wilfried Mestdagh

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
Hello,

If I do following:
for n := 0 to paramcount - 1 do showmessage(paramstr(n));

Then I have NOT the last parameter on command line, if do:
for n := 1 to paramcount do ..

then I have all parameters. I use Delph5 pro. Seems a bug to me ?

Justin Pitts

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
The docs are a bit goofy about this.
ParamCount is the number of PARAMETERS e.g. ParamStr(ParamCount) gives the
last parameter. ParamStr(0) gives the command (e.g. c:\mypath\myexe.exe )
therefore
for n := 0 to ParamCount do
showmessage(paramstr(n));
gives a breakdown of the entire commandline

not really a (code) bug, just poorly documented (which IS considered a bug
in some shops ;)

HTH
Justin

Wilfried Mestdagh <wilfrie...@csi.com> wrote in message
news:87c297$3o...@bornews.borland.com...

philippe_ranger

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
<<Wilfried:

then I have all parameters. I use Delph5 pro. Seems a bug to me ?
>>

Why do you think so? Help for ParamStr() --

----------------
Index is an expression of type Integer. ParamStr returns the parameter from
the command line that corresponds to Index, or an empty string if Index is
greater than ParamCount. For example, an Index value of 2 returns the second
command-line parameter.

ParamStr(0) returns the path and file name of the executing program (for
example, C:\TEST\MYPROG.EXE).
----------------

You have n params, numbered from 1 to n, and paramStr(0) always returns the
full path to the current exe.

PhR

Nick Hodges (TeamB)

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
On Thu, 3 Feb 2000 14:57:16 +0100, "Wilfried Mestdagh"
<wilfrie...@csi.com> wrote:

>Hello,
>
>If I do following:
>for n := 0 to paramcount - 1 do showmessage(paramstr(n));
>
>Then I have NOT the last parameter on command line, if do:
>for n := 1 to paramcount do ..
>

>then I have all parameters. I use Delph5 pro. Seems a bug to me ?

Nope, no bug. It is working exactly as designed and documented. From
the Delphi help --

"ParamStr returns the parameter from the command line that corresponds
to Index, or an empty string if Index is greater than ParamCount. For
example, an Index value of 2 returns the second command-line
parameter.

ParamStr(0) returns the path and file name of the executing program
(for example, C:\TEST\MYPROG.EXE)."


Nick Hodges - TeamB
Xapware Technologies -- http://www.xapware.com

Wilfried Mestdagh

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
Thanks, its indeed right documented, it was just confusing because of the
example in the help witch states: fro n := 0 to paramcount - 1

thx, Wilfried

Rudy Velthuis

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
Wilfried Mestdagh wrote...

>Thanks, its indeed right documented, it was just confusing because of the
>example in the help witch states: fro n := 0 to paramcount - 1

You're right. That example should be changed. I hope Janet sees this (I
changed the subject line). If not, she should be told by e-mail.
--
Rudy Velthuis

Craig Stuntz

unread,
Feb 3, 2000, 3:00:00 AM2/3/00
to
Justin Pitts wrote:
>
> not really a (code) bug, just poorly documented (which IS considered a bug

What's unclear to you about the ParamCount docs? Makes sense to me...

IMHO,

-Craig

--
Craig Stuntz cstuntz@no_spam.vertexsoftware.com
---------------- -----------------------------
Delphi Developer Vertex Systems Corporation
& Cat Wrangler http://www.vertexsoftware.com

0 new messages