While testing my app, I entered the following commandline in the IDE's Run/Command box:
To get a count of the parameters, I coded:
This returns 1, where I was expecting 3. I don't understand why. I have read the help, and I don't see the problem.
So I substituted the following loop to count parameters:
There are no errors and CmdCount always comes out fine.
So, I'm not stuck for a solution, but I am wondering what I'm misunderstanding about Parsecount. Can anyone explain why the count of those parameters came back as 1 and not 3?
There's a second part to this topic:
When I was coding the above loop, I was initially concerned that Command$(i) would cause an error when i is greater than the actual number of parameters.
I'd never used TRY before, and I thought this was a good place for it. So I coded this test:
but Command$(i) appears to be very forgiving and generates no runtime error.
And since there was no error, the Catch is never triggered. (I always use #Dim All, and while debugging have tools on and debug error on - no errors detected.)
It seems to me that there's something special about Command$() and so, (in addition to my question above about Parsecount), I was wondering if anyone can shed some light on these matters for me.
Thanks!
/g:2011-11-11 "E:\Test Code\test files\*.*" /b:-
Code:
CmdCount = Parsecount(Command$)
So I substituted the following loop to count parameters:
Code:
MaxParams = 5 For i = MaxParams To 1 Step -1 If Command$(i) = "" Then CmdCount = i -1 'could go to 0 if no params given... End If Next i
So, I'm not stuck for a solution, but I am wondering what I'm misunderstanding about Parsecount. Can anyone explain why the count of those parameters came back as 1 and not 3?
There's a second part to this topic:
When I was coding the above loop, I was initially concerned that Command$(i) would cause an error when i is greater than the actual number of parameters.
I'd never used TRY before, and I thought this was a good place for it. So I coded this test:
Code:
For i = MaxParams To 1 Step -1 Try x = Command$(i) Catch CmdCount = i -1 'could go to 0 if no params given... End Try next i
And since there was no error, the Catch is never triggered. (I always use #Dim All, and while debugging have tools on and debug error on - no errors detected.)
It seems to me that there's something special about Command$() and so, (in addition to my question above about Parsecount), I was wondering if anyone can shed some light on these matters for me.
Thanks!
Comment