xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

PCount()

Returns the number of passed parameters.

Syntax

PCount() --> nParamCount

Return

The function returns a numeric value indicating the number of parameters passed to a function, procedure or method.

Description

PCount() reports the number of parameters passed to a called function, procedure or method. Note that if parameters are omitted in a call, they are initialized with NIL in the called routine. PCount() reports the last parameter passed to a called routine (see the example).

Info

See also:FUNCTION, HB_ArgC(), PValue(), PROCEDURE, Valtype()
Category: Debug functions , Environment functions
Source:vm\pcount.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows the result of PCount() when a function is
// called with different numbers of parameters. Omitted parameters
// are implicitely passed as NIL values.

   PROCEDURE Main
      ? Test()                         // result: 0

      ? Test( "A" )                    // result: 1
      ? Test( NIL )                    // result: 1

      ? Test( "A", "B" )               // result: 2
      ? Test( "A",     )               // result: 2
      ? Test( "A", NIL )               // result: 2
      ? Test(    , "B" )               // result: 2
      ? Test(    ,     )               // result: 2

      ? Test( "A", "B", "C" )          // result: 3
      ? Test( "A",    , "C" )          // result: 3
      ? Test(    ,    , "C" )          // result: 3
      ? Test(    ,    , NIL )          // result: 3
      ? Test(    ,    ,     )          // result: 3
   RETURN

   FUNCTION Test
   RETURN PCount()

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe