PByReference - Check if a parameter was passed by reference

Top  Previous  Next

Syntax

 

<lByReference> := PByReference(<nParameterNumber>)

 

Parameters

 

<nParameterNumber>

 

Number of parameter to check for reference passing

 

Return value

 

A logical value indicating if parameter number <nParameterNumber> was passed by reference to the function calling PByReference.

 

Description

 

PByReference checks the parameter list passed to the calling function if a parameter was passed by reference. Omitted parameters are qualified as "passed by value" and hence a .F. value is returned for them.

 

Classification

 

Core

 

Category

 

Miscellaneous

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL a,b

 

* This call will result in the output of "Sub(ref,val,val,val)"

Sub(@a,,b,0)

 

* This call will result in the output of "Sub(val,val,ref,val)"

Sub(a,NIL,@b)

 

RETURN NIL

 

 

FUNCTION Sub

 

LOCAL s,n

 

* Start the output string

s := "Sub("

 

* Check 4 parameters

FOR n := 1 TO 4

 

   * Add passing type to output sring

   s += IIF( PByReference(n), "ref", "val") + ","

 

NEXT n

 

* round off the output string

s := Left(s,Len(s)-1)+")"

 

* Show the result

? s

 

RETURN NIL