Click to Rate and Give Feedback
MSDN
MSDN Library
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual FoxPro 9.0 SP2
PCOUNT( ) Function

Returns the number of parameters passed to the current program, procedure, or user-defined function.

PCOUNT( )

Numeric

PCOUNT( ) is useful for determining how many parameters are passed to the current program, procedure, or user-defined function.

Example 1 calls a procedure and displays in a wait window the number of parameters passed.

Example 2 uses a procedure to display the average of 4 values.

Example 1

DO testpar WITH 1,2,3

PROCEDURE testpar
PARAMETERS gn1,gn2,gn3
gcMessage = 'PCOUNT( ) ='+ALLTRIM(STR(PCOUNT( )))
WAIT WINDOW (gcMessage)
RETURN

Example 2

SET TALK OFF
gnVal1 = 10
gnVal2 = 20
gnVal3 = 30
gnVal4 = 15
gnMin = getavg(gnVal1, gnVal2, gnVal3, gnVal4)
? 'Average value is '
?? gnMin

* This user-defined function permits up to 9 parameters to be passed.
* It uses the PCOUNT( ) function to determine how many
* were passed and returns the average value.

FUNCTION getavg
PARAMETERS gnPara1,gnPara2,gnPara3,gnPara4,gnPara5, ;
   gnPara6,gnPara7,gnPara8,gnPara9
IF PCOUNT( ) = 0
   RETURN 0
ENDIF
gnResult = 0
FOR gnCount = 1 to PARAMETERS( )
   gcCompare = 'gnPara' +(STR(gnCount,1))
   gnResult = gnResult + EVAL(gcCompare)
ENDFOR
gnResult = gnResult / (gnCount - 1)
RETURN gnResult
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker