xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

PValue()

Retrieves the value of a parameter passed to a function, method or procedure.

Syntax

PValue( <nParamPos> ) --> xParamValue

Arguments

<nParamPos>
This is a numeric value indicating the ordinal position of the parameter to check.

Return

The function returns the value of the parameter at position <nParamPos> passed to a function, method or procedure. If <nParamPos> is larger than PCount(), the return value is NIL.

Description

PValue() is useful to retrieve the value of a parameter when a function, method or procedure is called with more arguments than are declared in the formal argument list.

Info

See also:PCount(), HB_AParams(), HB_ArgV(), Valtype()
Category: Debug functions , Environment functions , xHarbour extensions
Source:vm\pvalue.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example declares a function with an unknown number
// of parameters. The value of each parameter is retrieved
// with PValue().

   PROCEDURE Main

      ? Average( 10, 20 )                  // result: 15.00
      ? Average( 1,2,3,4,5,6,7,8,9,10 )    // result: 5.50

   RETURN


   FUNCTION Average( ... )
      LOCAL nSum := 0, i, imax

      imax := PCount()                     // number of passed arguments

      FOR i:=1 TO imax                     // sum data
         nSum += PValue( i )
      NEXT

   RETURN ( nSum / imax )

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