Revision [14462]

This is an old revision of KeyPgVaArg made by CountingPine on 2009-08-29 21:57:34.

 

VA_ARG


Returns the current argument from a variable argument list

Syntax:
variable = va_arg ( argument_list, DataType datatype )

Description:
The va_arg macro allows the use of a variable number of arguments within a function. va_arg returns the current argument in the list, argument_list, with an expected data type of datatype. Before va_arg can be used, it must be Initialized with the command KeyPgVaFirst va_first. Unlike the C macro with the same name, va_arg does not automatically increment argument_list to the next argument within the list. The command KeyPgVaNext va_next must be used for this purpose.

Examples:
Function Avg CDecl (Count As Integer, ... ) As Double
    Dim ARG As Any Ptr
    Dim SUM As Double = 0
    Dim i As Integer
   
    ARG = va_first()

    For i = 1 To COUNT
        SUM += va_arg(ARG, Double)
        ARG = va_next(ARG,Double)
    Next i
    Return SUM/COUNT
End Function

Print AVG (4, 3.4,5.0,3.2,4.1)
Print AVG (2, 65.2,454.65481)

Sleep


The output would look like:
3.925
259.927405


Dialect Differences:
Differences from QB:
See also:
Back to Procedures
Back to Variable Argument list
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode