View Single Post
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-30-2010 , 13:40   Re: Dynamic number of arguments in functions
Reply With Quote #13

Quote:
Originally Posted by alexx109 View Post
And what about by-reference vars? Arrays are still passed by-ref even as a dynamic argument catched by get_arg?

And about int vars as ref, in "normal" function headers we use & to flag them as passed-by-ref...

I guess it is through set_string, set_array and set_param_byref, am I correct?
No, those functions are used in dynamic natives.

Here is an example for an array in dynamic arguments:
Code:
foo( ) {     new iArray[ 32 ];     // pretend the array has values         EmptyArray( iArray, sizeof( iArray ) ); } bar( ) {     new iValue = 3;     GetValue( iValue );     // iValue = 5 now } // EmptyArray( array[], const size ) EmptyArray( ... ) {     new size = getarg( 1 );         for( new i = 0; i < size; i++ )     {         setarg( 0, i, 0 );         // setarg( arg, array_index, value )         // same as doing:         array[ i ] = 0;     } } // GetValue( &value ) GetValue( ... ) {     setarg( 0, _, 5 ); }

I'm not sure about the byref integer, but the array should work.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 09-30-2010 at 13:44.
Exolent[jNr] is offline