xHarbour Reference Documentation > Function Reference |
Retrieves the value of a parameter passed to a function, method or procedure.
PValue( <nParamPos> ) --> xParamValue
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.
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.
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 |
// 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 )
http://www.xHarbour.com