{{fbdoc item="title" value="CVA_COPY"}}----
Macro to initialize variadic argument list object variable from an already initialized variadic argument list object variable

{{fbdoc item="syntax"}}##
	**cva_copy**( //dst_list//, //src_list// )
##
{{fbdoc item="param"}}
	##//dst_list//##
		destination ##[[KeyPgCvaList|cva_list]]## variable to initialize
	##//src_list//##
		source ##[[KeyPgCvaList|cva_list]]## variable to copy from

{{fbdoc item="desc"}}
	Copies one ##[[KeyPgCvaList|cva_list]]## type variable to another ##[[KeyPgCvaList|cva_list]]## type variable.  ##//dst_list//## is initialized using current state of ##//src_list//##
	
	##//src_list//## must already have been initialized with a previous ##[[KeyPgCvaStart|cva_start]]## or ##**cva_copy**## statement.
	
	##**cva_copy**## is like a copy constructor for the a variadic argument list object and must eventually have a matching call to ##[[KeyPgCvaEnd|cva_end]]##, which is like the destructor.  After ##[[KeyPgCvaEnd|cva_end]]## for ##//dst_list//## has been called, ##//dst_list//## can be reused and reinitialized with another call to ##[[KeyPgCvaStart|cva_start]]## or ##**cva_copy**##.  The ##**cva_copy**## and ##[[KeyPgCvaEnd|cva_end]]## calls must both be called in the same procedure (for cross platform compatibility).
	
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/procs/cva_copy1.bas"}}%%(freebasic)
'' example of using cva_copy to create
'' a copy of the variable argument list

Sub proc CDecl(count As Integer, ... )
	Dim args1 As cva_list
	Dim args2 As cva_list

	'' first list
	cva_start( args1, count )

	'' create a copy
	cva_copy( args2, args1 )

	For i As Integer = 1 To count
		Print cva_arg( args1, Integer ), cva_arg( args2, Integer )
	Next
	
	'' clean-up
	cva_end( args2 )
	cva_end( args1 )

End Sub

proc( 4, 4000, 300, 20, 1 )
%%

{{fbdoc item="filename" value="examples/manual/procs/cva_copy2.bas"}}%%(freebasic)
'' example of using cva_copy to create
'' a copy of the variable argument list
'' and pass it to another procedure

Sub vproc CDecl(count As Integer, byref args as cva_list )

	'' if we don't know that caller made a copy
	'' of args, it is safe to make our own copy
	'' and leave the passed in args untouched

	Dim a As cva_list
	cva_copy( a, args )

	print "vproc"
	For i As Integer = 1 To count
		Print cva_arg( a, Integer )
	Next
	
	'' clean-up
	cva_end( a )

End Sub

Sub proc CDecl(count As Integer, ... )

	Dim args As cva_list
	cva_start( args, count )

	'' if don't know that the called procedure
	'' will make it's own copy, it is safe to
	'' make a copy here and pass that instead

	Dim tmp as cva_list
	cva_copy( tmp, args )
	vproc( count, tmp )
	cva_end( tmp )

	'' args is still valid, we can use it
	print "proc"
	For i As Integer = 1 To count
		Print cva_arg( args, Integer )
	Next
	
	'' clean-up
	cva_end( args )

End Sub

proc( 4, 4000, 300, 20, 1 )
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__cva_copy""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- [[KeyPgDots|... (Ellipsis)]]
	- ##[[KeyPgCvaArg|cva_arg]]##
	- ##[[KeyPgCvaEnd|cva_end]]##
	- ##[[KeyPgCvaList|cva_list]]##
	- ##[[KeyPgCvaStart|cva_start]]##

{{fbdoc item="back" value="CatPgProcedures|Procedures"}}{{fbdoc item="back" value="CatPgVarArg|Variable Argument list"}}