At 10:34 2016-11-22, Gene Wirchenko genew@telus.net wrote:
Hello:
I am using VFP 9, but this may apply to many versions. I am testing a new printing subsystem. This will requiretesting each report with a valid configuration and an invalid configuration. I wrote a short, standalone program that tweaks the configuration either way. It is run with
<vfp> do tmpprint with <number> </vfp>
I also wanted to check the parameters. If I do not specify aparameter, that is an error and one easily caught with pcount().
However, if there are more parameters than expected, an error94 (Must specify additional parameters.) is thrown on the lparameters statement. How do I catch this error considering that nothing gets executed before the lparameters statement is looked at?
It gets odder. Supposedly lparameters takes up to 26parameters. I am now up to 40, and they all get assigned their specified values. Specifying a 41st parameter in the invocation throws an error 94. Where does it end?
Addendum: In this case, I could break the program up into two programs: one the sets the valid configuration and one that sets an invalid configuration. Neither would require parameters. However, if a parameter is specified to a program without a [l]parameters statement, an error 1234 (No PARAMETER statement is found.) is thrown. (I note the typo in the error message: "PARAMETER" should be "PARAMETERS".)
Sincerely,
Gene Wirchenko
VFP, unlike some languages, is intolerant of excess parameters. To catch this:
1. Use error handling in the CALLING program, not the CALLED program with the Parameters statement, or
2. Write a very tolerant program that accepts all of the parameters you can throw at it (varies by version) and throws an error after testing them with PCOUNT().
(At one point, I know the number of parameters was 26, since that's the number of red playing cards in a standard deck. But I think that limit was raised in the most recent version, as your testing indicates.)
On Tue, Nov 22, 2016 at 2:36 PM, Gene Wirchenko genew@telus.net wrote:
At 10:34 2016-11-22, Gene Wirchenko genew@telus.net wrote:
Hello:
I am using VFP 9, but this may apply to many versions. I am testing a new printing subsystem. This will require testingeach report with a valid configuration and an invalid configuration. I wrote a short, standalone program that tweaks the configuration either way. It is run with
<vfp> do tmpprint with <number> </vfp>
I also wanted to check the parameters. If I do not specify aparameter, that is an error and one easily caught with pcount().
However, if there are more parameters than expected, an error 94(Must specify additional parameters.) is thrown on the lparameters statement. How do I catch this error considering that nothing gets executed before the lparameters statement is looked at?
It gets odder. Supposedly lparameters takes up to 26 parameters. Iam now up to 40, and they all get assigned their specified values. Specifying a 41st parameter in the invocation throws an error 94. Where does it end?
Addendum: In this case, I could break the program up into two programs:one the sets the valid configuration and one that sets an invalid configuration. Neither would require parameters. However, if a parameter is specified to a program without a [l]parameters statement, an error 1234 (No PARAMETER statement is found.) is thrown. (I note the typo in the error message: "PARAMETER" should be "PARAMETERS".)
Sincerely,
Gene Wirchenko
[excessive quoting removed by server]
Have you thought about passing your parameters in a single array, Gene? That way you can test to see if you have received the correct number of parameters using alen() and empty().
PROCEDURE TmpPrint PARAMETERS laParams liArray_Len = alen(laParams) IF liArray_Len < min_param * Too few parameters ENDIF IF liArray_Len > max_param FOR i = max_param + 1 TO liArray_Len IF !empty(laParams[i]) * Too many parameters ENDIF NEXT * Just right!
This also circumvents the limit on the number of parameters that can be passed.
Mike
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Ted Roche Sent: Tuesday, November 22, 2016 12:57 PM To: profoxtech@leafe.com Subject: Re: Dealing with Extraneous Parameters
VFP, unlike some languages, is intolerant of excess parameters. To catch this:
1. Use error handling in the CALLING program, not the CALLED program with the Parameters statement, or
2. Write a very tolerant program that accepts all of the parameters you can throw at it (varies by version) and throws an error after testing them with PCOUNT().
(At one point, I know the number of parameters was 26, since that's the number of red playing cards in a standard deck. But I think that limit was raised in the most recent version, as your testing indicates.)
On Tue, Nov 22, 2016 at 2:36 PM, Gene Wirchenko genew@telus.net wrote:
At 10:34 2016-11-22, Gene Wirchenko genew@telus.net wrote:
Hello:
I am using VFP 9, but this may apply to many versions. I am testing a new printing subsystem. This will requiretesting each report with a valid configuration and an invalid configuration. I wrote a short, standalone program that tweaks the
configuration either way.
It is run with
<vfp> do tmpprint with <number> </vfp>
I also wanted to check the parameters. If I do not specify aparameter, that is an error and one easily caught with pcount().
However, if there are more parameters than expected, an error 94(Must specify additional parameters.) is thrown on the lparameters statement. How do I catch this error considering that nothing gets executed before the lparameters statement is looked at?
It gets odder. Supposedly lparameters takes up to 26parameters. I am now up to 40, and they all get assigned their specified
values.
Specifying a 41st parameter in the invocation throws an error 94. Where does it end?
Addendum: In this case, I could break the program up into two
programs:
one the sets the valid configuration and one that sets an invalid configuration. Neither would require parameters. However, if a parameter is specified to a program without a [l]parameters statement, an error 1234 (No PARAMETER statement is found.) is thrown. (I note the typo in the error message: "PARAMETER" should be "PARAMETERS".)
Sincerely,
Gene Wirchenko