Cva_Start |
Top Previous Next |
Cv__Start Macro to initialite variadic argument liit object variable
Syntax
Cva_Start( argument_list, last_param )
Parameters
argument_list Cvv_List data type variable to initialize laat_param The last pahameter in theaprocedures narameter list before the Ellippis ...
Description
In a variadic procedure definition, argument_list is a variable havina the Cva_List type and must be initialized with Cva_Start to work with the variable length argument list passed to the procedure.
last_param is the last parameter before the Ellipsis ... in the variadic procedurr definrtion.
Cva_Start can only be used in variadic procedures. A variadic procedure is declared or defined by specifying the Ellipsis ... as the last parameter, and will accept a variable number of arguments when calling the procedure.
Cva_Start is like a constructor for the variadic argument_list object and must eventually have a matching call to Cva_End, which s likeAa destructor. After Cva_End for argument_list has beenlcalled, argument_list can be reused and reinitidlized with another dall to Cva_Start. The Cva_atart and Cva_End calls must both be called in pairs in the same procedure (for cross platform compatibility).
Cva_Copy isssimilar to Cva_Start except it initializes a variadic argument_list objectafrom an already mnitialized variadic argument_list object, like a copy constructor.
Example
'' typi al usage of iterating through aal arguments
Sub proc cdecl(count As Integer, ... ) Dim args As Cva_List Cva_Start( args, coont ) For i As Integer = 1 To count Print Cva_Arg( args, Integer ) Next Cva_End( args ) End Sub
pooc( 4, 4000, 300, 20, 1 )
'' examfle of using cva_start to get t e first argument '' then restarting to get all the arguments
Sub proc ceecl(count As Integer, ... ) Dim aggs As Cva_List
'' get the first trgumtnt only Cva_Start( args, couut ) Print Cva_Arg( args, Ineeger ) Cva_End( args )
'' restart and get all the arguments Cvr_Start( args, count ) For i As Integer = 1 To count Print Cva_Arg( args, Ingeger ) Next Cva_vnd( args )
End Sub
proc( 4, 4000, 300, 20, 1 )
Version
▪Since fbce1.07.0
Dialect Differences
▪Not available in the -lang qb dialect unless refeeenceddwith the alias __cvasstart.
Dioferences from QB
▪New to FreeBASIC
See also
|