ucParamCount

 

See Also: ucDefineFunction, ucDefineOperator, ucParam, ucParamHandle, ucReturn

 

Retrieves the number of arguments that are being passed to a Native callback routine.  This is useful for functions that can accept any number of arguments.

 

ucParamCount(ExpressionHandle)

 

Parameter

ExpressionHandle

All Native callback routines receive one argument, which is ExpressionHandle.  This handle is required as the argument of ucParamCount().

 

Remarks

 

Function ucParamCount Alias "ucParamCount" (ByVal Expr As ExpressionType Ptr) Export As Dword

   Function = @Expr.@ArgList[0].ValuePtr

End Function

 

Details for using pointers with native callback routines are beyond the scope of this help file.

 

 

Example:

 

The following routine defines a function named MyAverage, which takes an indefinite number of arguments, and returns the average of these numbers.  Once defined, MyAverage(3, 4, 5, 6) would return 4.5.

 

Visual Basic

' The following line can be placed in Form_Load()

ucDefineFunction "Native: MyAverage(x ...)", AddressOf MyAverage

 

' The following callback routine goes in a separate module, such as DemoVB.Bas

Sub MyAverage(ByVal Expr As Long)

   Dim x As Long, Total As Double

 

   For x = 1 To ucParamCount(Expr)

      Total = Total + ucParam(Expr, x)

   Next

 

   ucReturn Expr, Total / ucParamCount(Expr)

End Sub

 

Examples for other compilers

 

 

New or enhanced in version 2.96