Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PARAMETERS() bug?
Message
From
11/11/2002 13:06:27
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
11/11/2002 06:00:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00720910
Message ID:
00721137
Views:
32
>I have put PARAMETERS() below the LPARAMETERS to see how much parameters have been passed to my UDF.
>I have put to see if there was a too low or too many parameters passed.
>
>It goes something like this.
>
>
>
>FUNCTION myUDF()
>     LPARAMETERS para1, para2, para3, para4
>          IF PARA() < 2 OR PARA() > 4
>              RETURN .F.
>          ENDIF
>and rest....
>
>
>
>
>Now, if there are less parameters passed it returns .F., everything is OK.
>
>But, if there are more parameters passed (in this case more than 4), it displays error before program reached to the line where is IF statement, and program is out!!!
>
>Why is this happening? Is this a kind of a bug?
>Is there a way to avoide this?

Actually, this needs some understanding of the calling mechanism. Fox checks the number of parameters before really calling the UDF, and throws the error if there are too many of them. We enjoy the possibility of calling the UDF with fewer parameters - and have the Parameters() (or, better, pcount()) function to check the number actually passed.

Easiest way out of this is just to add ", p11, p12, ..., p27" to your LParameters line. If anyone calls it with more than 27 (or whatever was the physical limit), error surely follows.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform